Search Unity

ClientWebSocket connectAsync freezes on 3rd try

Discussion in 'Multiplayer' started by BUWbrean, Dec 13, 2017.

  1. BUWbrean

    BUWbrean

    Joined:
    May 4, 2017
    Posts:
    9
    Hi,

    I am currently working on a WebSocket Library that uses the Experimental .Net 4.6 . When I try to connect multiple times to a server that does not exist I get an Exception for the first 2 tries (which is fine so far) but the ConnectAsync freezes on the 3rd try.
    See this gist for example code. The output for this code is this:

    HTML:
    1. try to connect
    Connection Error
    2. try to connect
    Connection Error
    3. try to connect
    The 3rd "Connection Error" is never shown/the task is frozen.
    Any idea how I can solve this? Ideally it would try to connect to the server forever (I could add some delay that increases over time, but in theory I'd like to have a loop until my server becomes available).
     
  2. BUWbrean

    BUWbrean

    Joined:
    May 4, 2017
    Posts:
    9
    I tested a bit more and it looks like it is always the 3rd unsuccessful connection attempt, things like successfully connecting on the 2nd attempt then disconnect and reconnect works. Only 3 unsuccessful connection attempts in a row result in the freeze.

    I assume this might be a .Net-Framework issue, so I also chatted with the microsoft support and created an issue on the MS feeback hub as well as the communty forum.
     
    Last edited: Dec 14, 2017
  3. delphinius81

    delphinius81

    Joined:
    Mar 6, 2012
    Posts:
    57
    Came across this bug as well (spent 2 days trying to figure out why). Seems to be fixed in Unity 2018.