Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

UWP multiplayer disconnects with UNet

Discussion in 'Windows' started by Doghelmer, Aug 15, 2020.

  1. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I'm having with a host-client multiplayer game running on UWP and UNet. When using the same network code as in my normal Win/Mac/Linux build, the client receives a ton of messages in their output log that look like this:

    Warning: received system packet belongs to wrong session


    Then, after several minutes of playtime, the client will disconnect from the host. This happens consistently whenever the UWP player is a client.

    Unfortunately I haven't been able to find any info about this beyond this old thread. No amount of messing with ConnectionConfig settings or other settings has yielded any difference in results.

    I was curious if this sounded familiar to anyone?
     
  2. timke

    timke

    Unity Technologies

    Joined:
    Nov 30, 2017
    Posts:
    372
    Hey,

    So, full disclosure, I don't know much about UNET but on a previous team (before working at Unity) we also had issues with UNET working properly on UWP. It was a different problem were building a UWP app on one PC didn't sync properly with a UWP app (using the same code) built on a different PC. In our case, we had to use the same binaries for all network clients. However, aside from the fact that's not possible in your case, this sounds like a different problem.

    The warning basically means the client received a "System" packet from a different Host than the one it's currently connected to. There might be a reasonable explanation for this, e.g. another Host on the network is sending System packets which the client just ignores. So it could just be a red-herring and the real cause of the disconnects is something else. Again, I don't know that for sure; it's just a guess.

    Some follow-up questions:
    • Do you also see this other warning: "Warning: received user packet belongs to wrong session"?
    • Does the network game run properly, i.e. game objects update, until the client is disconnected?
    • Any issues or warnings with UWP searching for a Host and connecting to the session?
    • Sorry but gotta ask: did you enable both internetClient and internetClientServer permissions for UWP?
    • Do other Host/Client configurations work: UWP Host-Win Client, UWP Host-UWP-Client, etc.?
    Have you tried posting this issue on "Connect Games" forum? Might get better help there.
     
  3. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    - I don't see the other warning on either the client or host log.
    - The game does run properly until the client is disconnected, I'm not seeing anything out of the ordinary in regards to the gameplay.
    - I'm not seeing any unusual issues or warnings on either the host or client while the client is connecting.
    - I do have both internetClient and internetClientServer permissions activated.
    - All of the host/client configurations work. The Windows version does not receive the warning messages or get disconnected.

    So unfortunately I don't see any leads here. Also of note, I'm doing most of the testing with multiple windows on the same PC, running games through the internet and through UNet matchmaking, though I've also tried this with multiple PCs.

    As another note, the Xbox certification testers who worked on this apparently did not have this issue at all. This appears to be happening exclusively on my end.
     
    Last edited: Aug 19, 2020
  4. timke

    timke

    Unity Technologies

    Joined:
    Nov 30, 2017
    Posts:
    372
    Thanks for the information.

    That may explain the Warning messages: if your Clients are using the same Port, then each app instance will receive "system" packets for all the active sessions. Or it could be the packets are being routed to the wrong instance.
    But I'm guessing your PCs are all on the same local network, so packet routing is going to be dependent on your local router's behavior. I'm guessing your PCs are all connected to a WiFi router and not to network switch.
    This would indicate something is amiss with your network configuration or UNET isn't playing nice with your network.

    So, this is my best guess to what's happening: the "keep alive" packets or messages that tell the session manager to keep a connection open are somehow being blocked or mis-routed. Since gameplay don't appear to be effected, this is really bizarre. "Keep alive" message should just be piggy-backed onto the normal traffic for a connection. But it seems like UNET does something different and these packets are dispatched separately.

    Also, I don't know why this issue only occurs for UWP and not for WindowsStandalone, there could be some Windows firewall shenanigans going on.

    So, here are some suggestions on how to investigate this:
    • Do nothing; if it's not causing a Cert failure then maybe don't need to worry about it
    • Use a Network Analyzer (aka packet sniffer) to investigate the routing patters on your local network; these kind of problems are often caused by misconfigured firewalls
    • Try using different Port numbers in your app or maybe use a random Port number for each instance (don't know how this works in UNET)
    • Put each PC on different subnet and see if the problem still occurs; using multiple WiFi routers easiest way to do this or (if your PC has multiple NICs) can also configure Windows Internet Connection Sharing so a PC acts as a gateway for another PC
    • Try connecting your PCs through a network switch (hub) instead of WiFi or if you're currently using WiFi try connecting through a switch (if you have the hardware) this might change how packets are routed
    The goal is basically to identify who is at fault for blocking/misrouting packets: the network router, Windows (firewall), or the app itself.

    Sorry I can't provide more detailed info on how UNET actually works, but I hope this is helpful.
     
unityunity