NetworkServerSimple and NetworkClient

I have an issue where upon disconnecting from my network server the client seems to have trouble receiving messages from the server when attempting to reconnect. I have a back and forth like this…

Client connects
Server send authentication request
Client send credentials
Server sends response
Client loads game

This works perfect the first time, but i only get the connection message when i attempt to reconnect reconnect. If i restart the app it works fine again, until i disconnect and attempt to reconnect.

Client reconnects
Server send authentication request
…nada

Authentication request sent

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

Log: connection {2} has been disconnected by timeout; address {::ffff:192.168.4.166:62592}

This seems to indicate it timesout…but why?

Oddly enough if i set breakpoints at places in my code…it works. :eyes:

That would suggest it is a timing issue…

If i call GC.Collect(); before calling Connect again it seems to solve the problem. But only in the editor. When i make player build the problem persists,

Im at a loss for this issue. I cant seem to recreate it in a simple example. Not yet anyway. But i also cant understand why the forced GC solves it in the editor and not the built player.

Iv stripped almost everything but the minimum from my project and still have problems. Although, randomly sometimes its works on the second reconnect, then stops again when i attempt to reconnect a third time

Seems to involve network discovery. Still investigating

Iv removed the Usage of NetworkDiscovery from my sample and it seems to work. It might not be properly cleaning up when i StopBroadcast()

Developed a work around, i stop broadcast then wait 0.2s before connecting. Something is not getting cleaned up correctly when calling StopBroadcast()

Thanks for your post. This is apparently still a problem but your work around fixed things for me.