报错关键词:CENetThreadPool::Process - Exception; Unexpected protocol 相关关键词:Unity;Photon;PUN;MMO
1. 背景
在开发多人在线网络游戏的项目中,使用Photon PUN 2 作为客户端SDK,Photon Server (V4) 作为服务器端的SDK,它们之间的连接遇到了下文的问题。
2. 问题
在 Photon-LoadBalancing-xxx.log文件中报错,如下图: 报错的部分文本如下:
11448: 20:18:26.647 - 000000000B69F8A0: id = 0 [0] disconnected due to exception
11448: 20:18:26.648 - CENetThreadPool::Process - Exception - CENetPeerBase::HandleIncomingCommands() - PeerAppSelection()- Init: Unexpected protocol, expected value is between 1.2 and 1.7 : id = 0 [0] Datagram: 00 00 00 02 00 00 08 51 6B E2 FB CC 01 FF......
11448: 20:19:24.866 - 000000000B69EAA0: id = 1 [0] disconnected due to exception
11448: 20:19:24.866 - CENetThreadPool::Process - Exception - CENetPeerBase::HandleIncomingCommands() - PeerAppSelection()- Init: Unexpected protocol, expected value is between 1.2 and 1.7 : id = 1 [0] Datagram: 00 01 00 02 00 00 08 21 41 7B A4 DF 01 FF ......
6292: 20:20:36.574 - CThreadPool::Process - Exception - PeerAppSelection() - Init: Unexpected protocol, expected value is between 1.2 and 1.7
13852: 20:20:49.653 - CThreadPool::Process - Exception - PeerAppSelection() - Init: Unexpected protocol, expected value is between 1.2 and 1.7
6292: 20:21:03.261 - CThreadPool::Process - Exception - PeerAppSelection() - Init: Unexpected protocol, expected value is between 1.2 and 1.7
6292: 20:21:25.355 - CThreadPool::Process - Exception - PeerAppSelection() - Init: Unexpected protocol, expected value is between 1.2 and 1.7
6292: 20:21:34.544 - CThreadPool::Process - Exception - PeerAppSelection() - Init: Unexpected protocol, expected value is between 1.2 and 1.7
11448: 20:22:22.933 - 000000000B69F8A0: id = 2 [0] disconnected due to exception
11448: 20:22:22.933 - CENetThreadPool::Process - Exception - CENetPeerBase::HandleIncomingCommands() - PeerAppSelection()- Init: Unexpected protocol, expected value is between 1.2 and 1.7 : id = 2 [0] Datagram: 00 02 00 02 00 00 08 45 30 4C 65 87 01 FF......
11448: 20:22:26.279 - 000000000B69EAA0: id = 3 [0] disconnected due to exception
作为小白,一开始我也看不懂什么原因,经过多方努力查明了原因:协议序列化编码问题。主要是客户端和服务器端的版本适配的不是很好,需要我们手动操作一下。
3. 方法
在发起连接请求前,设定一下序列化协议的版本,如下的第一行代码:
PhotonNetwork.NetworkingClient.LoadBalancingPeer.SerializationProtocolType = ExitGames.Client.Photon.SerializationProtocol.GpBinaryV16;
isConnecting = PhotonNetwork.ConnectUsingSettings();
4. 结束语
希望本文对那些基于Photon技术开发、Unity开发的小白有所有帮助,少走弯路,节约时间。 欢迎大家交流技术问题。
|