Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

How do I prevent disconnection due to Error BadMessage?

Discussion in 'Connected Games' 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:
    2
    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. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    2,714
    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.