Search Unity

How do I prevent disconnection due to Error BadMessage?

Discussion in 'Multiplayer' started by cracknell_unity, May 8, 2018.

  1. cracknell_unity

    cracknell_unity

    Joined:
    Apr 25, 2018
    Posts:
    2
    Some of our players are being disconnected partway through a game. Logs show the client disconnects with NetworkError.BadMessage, and then the server reports them as timing out shortly after. There seem to be no other relevant logs.

    According to my research, BadMessage means the client received a non-data packet, probably due to a rare packet corruption. I know there's no avoiding that, but it why does it force my client to disconnect? Can I make it just ignore bad packets?

    Using Unity 2017.4.1 LTS.
     
  2. throzen

    throzen

    Joined:
    Jun 11, 2015
    Posts:
    6
    Hey cracknell_unity, I just found this thread after googling for this exact problem.
    Have you been able to find a workaround for this? I am having the same issues atm (Unity 2018.2.11f1), and havn't figured a way around it so far. :-/ right now I am studying the documentation of custom ConnectionConfig to see if maybe some settings there could help, but I suspect anything that could be done there would only change the threshold of when the error will occur (at best) and not completely remove it...
     
  3. cracknell_unity

    cracknell_unity

    Joined:
    Apr 25, 2018
    Posts:
    2
  4. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    UNET's LLAPI uses UDP, which means that messages will be dropped and all kinds of weird things will happen.
    It might be a LLAPI bug too, but you probably won't see a fix at this point and you won't be able to fix it yourself, since it's closed source.

    Unity's latest UNET version can use different low level transports now. You could try another UDP transport, or make your own, or consider TCP (where you won't have to worry about lost packets). Depends on the type of game you want to make too.