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 have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

NetworkServerSimple and NetworkClient

Discussion in 'Multiplayer' started by jbakerads, Dec 9, 2015.

  1. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    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
     
  2. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    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?
     
  3. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    Oddly enough if i set breakpoints at places in my code...it works. o_O
     
  4. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    That would suggest it is a timing issue..
     
  5. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    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,
     
  6. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    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.
     
  7. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    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
     
  8. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    Seems to involve network discovery. Still investigating
     
  9. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    Iv removed the Usage of NetworkDiscovery from my sample and it seems to work. It might not be properly cleaning up when i StopBroadcast()
     
  10. jbakerads

    jbakerads

    Joined:
    Nov 2, 2015
    Posts:
    11
    Developed a work around, i stop broadcast then wait 0.2s before connecting. Something is not getting cleaned up correctly when calling StopBroadcast()
     
  11. Code-ttt

    Code-ttt

    Joined:
    Oct 20, 2014
    Posts:
    9
    Thanks for your post. This is apparently still a problem but your work around fixed things for me.