Using RaiseEvent from a client (PUN2) throw an exception on the server (Realtime v4)

Hello

I'm actually trying to make a simple client-server application using PUN2 and Photon Realtime v4, and got a problem with the RaiseEvent method.

I'm actually using PUN2.5 and Photon Reatime 4.0.28.2962, and the following code:
byte[] data = new byte[] { 136, 137, 138 };
RaiseEventOptions reo = new RaiseEventOptions()
{
    TargetActors = targets,
    CachingOption = EventCaching.DoNotCache,
    InterestGroup = 0,
    Receivers = ReceiverGroup.Others
};
SendOptions so = new SendOptions
{
    Channel = 1,
    DeliveryMode = DeliveryMode.ReliableUnsequenced
}
PhotonNetwork.RaiseEvent(1, data, reo, so);
When I'm using this code, my client get instantly disconnected from the server, and I got the following error in my LoadBalancing logs:
14028: 20:33:37.234 - 0000000009CFE420: id = 6 [0] disconnected due to exception
14028: 20:33:37.235 - CENetThreadPool::Process - Exception - CENetPeerBase::HandleIncomingCommands() - CENetPeerBase::HandleIncomingCommands()- Unexpected: id = 6 [0] ENET_PROTOCOL_COMMAND type: 14 : id = 6 [0]
(followed by the datagram hex and string representations)
Also, the id is never the same.

Thanks for your help
Slaynash

Comments

  • hi, @Slaynash

    Please, make sure that you are using protocol 1.6. I believe that PUN2 uses 1.8 serialization protocol by default. Current version of selfhosted sdk does not support it

    best,
    ilya
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2019
    Hi @Slaynash,

    Thank you for choosing Photon!

    make sure that you are using protocol 1.6.
    This should be done on your behalf when you use ConnectUsingSettings with the ServerSettings configured for self-hosted Photon Server.

    If you use another connect methods, manually set the serialization protocol version like this before connecting:
    PhotonNetwork.NetworkingClient.LoadBalancingPeer.SerializationProtocolType = SerializationProtocol.GpBinaryV16;   // this is a workaround to use On Premise Servers, which don't support GpBinaryV18 yet.
  • Hello

    I am already using ConnectUsingSettings, and I also get some server logs telling that the packets are received as GpBinaryV16.

    I also just noticed that the "Unexpected id" is the same as the sender PeerId:
    (GSGame.log)
    2019-07-12 14:44:32,268 [9] DEBUG Photon.Hive.HivePeer - OnDisconnect: conId=7, reason=ServerDisconnect, reasonDetail=CENetPeerBase::HandleIncomingCommands() - Unexpected: id = 7 [0] ENET_PROTOCOL_COMMAND type: 14
    Thanks
    Slaynash
  • After some more tests, it seems that changing DeliveryMode.ReliableUnsequenced to DeliveryMode.Reliable fixed the problem.
    Maybe Protocol16 doesn't support it?
  • Protocol 16 is a serialization protocol
    Delivering works independently from it

    best,
    ilya
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2019
    Hi @Slaynash,

    I am already using ConnectUsingSettings, and I also get some server logs telling that the packets are received as GpBinaryV16.
    You use an old version, 2.5 (20th November 2018).
    Do you use websockets, this was added to 2.8.1
    Changed: When connecting to a Master Server directly (likely a Photon Server / OnPremise) with WebSockets, PUN now automatically uses a compatible serialization protocol (GpBinaryV16).