Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

A client disconnects from the server, another client got disconnected. #264

Open
PyeonggukLee opened this issue Apr 23, 2019 · 7 comments
Open

Comments

@PyeonggukLee
Copy link
Contributor

Version Number and Operating System(s):

don't know the version but latest upstream/develop merged.
Windows 10 64bit

Expected behavior:

when a specific client disconnects from the server, that client should be disconnected, not another.

Actual behavior:

when client A disconnects from the server, client B got disconnected from the server. (messed up)

Steps to reproduce:

https://github.com/PyeonggukLee/ForgeNetworkingRemastered/tree/disconnect-issue
Here is my forked branch for the issue.

  1. clone and build it. (I tested this on Unity 2018.3.0f2)
  2. execute 1 as a host(server) (better execute it in unity editor.)
  3. execute 2 clients more.
  4. disconnect one of any clients then you will see the problem.

[Optional] Discord Username:

PyeNog

@PyeonggukLee
Copy link
Contributor Author

PyeonggukLee commented Apr 29, 2019

More info I found from testing:
Calling UDPClient.Disconnect(true) makes the problem.

How I've tested this issue:
when ESC key pressed, calling below:

switch (NetworkManager.Instance.Networker)
{
    case UDPClient client:
        client.Disconnect(true);  // This makes the issue.
        //client.Disconnect(false); // This is OK.
	break;
}

@phalasz
Copy link
Contributor

phalasz commented Dec 30, 2019

I ran into this issue as well (using latest develop branch) with one server and multiple clients running on the same machine. Force disconnect (run on application quit) seems to be causing this. Will double check whether it affects clients on different machines.

On a different project with a develop branch from before April 2019 I have not seen the issue and multiple client worked fine on the same machine.

@phalasz
Copy link
Contributor

phalasz commented Dec 30, 2019

Investigating this further, the code on the develop branch waits for a timeout on the player disconnecting when the app is closed while the master branch code immediatelly disconnects. Both examples using the CubeForge example.

@phalasz
Copy link
Contributor

phalasz commented Dec 30, 2019

Interestingly I'm seeing a WSACancelBlockingCall exception on the client read thread after the client disconnects. Might be a red herring though

Also if I use the pre refactor code/master branch for the client and the latest develop for the server then disconnections work as expected even for multiple clients on the same machine. Doing it the other way around where server is the pre refactor code and the client is the latest develop then the issue is reproducible again.

This seems to suggest that the issue is with the refactored UDPClient code? 🤔

@phalasz
Copy link
Contributor

phalasz commented Dec 30, 2019

So to summarise what I am experiencing with latest develop branch (issue seems to be slightly different from the original issue above):

If with multiple clients on the same machine connected to the server on the same machine. One client disconnects (eg.: close application which will call UDPClient.Disconnect(false)) the connection closed message is never sent to the server, instead there will be an exception on the client's read thread (https://github.com/BeardedManStudios/ForgeNetworkingRemastered/blob/develop/ForgeUnity/Assets/BeardedManStudios/Scripts/Networking/Forge/Networking/UDPClient.cs#L393).
The server after this times out the client that tried to disconnect and will also disconnect the other clients as well.

If I debug step through the UDPClient.Disconnect() method I see the connection close message send line and since I'm slower then the computer while stepping through code the client will disconnect correctly and all other clients stay connected.

@phalasz
Copy link
Contributor

phalasz commented Dec 31, 2019

Looks like this commit (f5fbbb8) breaks the client disconnection. The commit before it works (after the two minor fixes of removing an #endif and adding a missing #region)

@phalasz
Copy link
Contributor

phalasz commented Mar 2, 2020

Should we just add a little wait in there to allow the message to be sent? Like when stepping through the disconnect code it is slower? Or maybe a wait on the ack on the disconnect message?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants