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

Socket: Cannot receive, error: Socket is not connected(57)

Discussion in 'Multiplayer' started by diesen1, Jun 24, 2015.

  1. diesen1

    diesen1

    Joined:
    Jul 3, 2014
    Posts:
    15
    My app crashed on ios when i resume from suspend ( let it run in the background for 40 seconds and then reactivated).
    I connect the device to Xcode and I saw that crash happening after the message beow appears more than 100 times in the logs

    Socket: Cannot receive, error: Socket is not connected(57)
    (Filename: Line: 475)
     
  2. UNNYHOG

    UNNYHOG

    Joined:
    Nov 18, 2012
    Posts:
    10
    I have this issue right now.
    The biggest problem problem that I don't even know which method causes this.

    I though it was from NetworkTransport.Receive, but according to my logs it's not.
     
  3. Smile Dragon

    Smile Dragon

    Joined:
    Jan 7, 2012
    Posts:
    7
    Hi, same problem here, on IOS when the connection client/server is done, if I put the client device in suspend mode for some sec. and reactivate it, I've no possibility to reconnect to the server...(the error is the same Socket: Cannot receive, error: Socket is not connected(57))
    I have to close the App and restart it, and the client reconnect again. But I don't want to shout down the app because I use the client in Kiosk mode.

    Does someone solved it?

    Need a possible solution very urgent, please help.

    Thanks
     
  4. Flarup

    Flarup

    Joined:
    Jan 7, 2010
    Posts:
    164
    Hi,

    I have this problem as well. I'm using Unity 5.2.3p3 and building for iOS. Have anyone managed to find a fix or workaround?

    Thanks a lot in advance.

    Kind regards,
    Uffe Flarup
     
  5. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    182
    Bump, so reason behind this is because NetworkClient connection is not closed up completely, and there are couple things you can do to fix this i guess...

    1. Under Connected status: you will need to disconnect your network before app go into suspending mode, so simply use OnApplicationFocus(bool pause), and when is going to pause simply use NetworkClient.Disconnect(), and when it comes back up, simply call NetworkClient.Connect().

    2. Under Connecting Status: this is something I am still trying to figure out, while connecting, I do the samething above(but not calling NetworkClient.Conect() when coming back from suspend mode). The status will simply change from disconnected to reconnecting... which I somehow find it hard to believe... to find status of your NetworkClient.cs the easy way: simply create a script that inherit NetworkClient.cs , I called it StupidUnityBugFixNetworkClient.cs, then revealed their protected status variable.
     
    Last edited: Mar 29, 2016