Still problems with disconnect in UNET (Unity 5.4.2f2)

Very frustrating. If a client just closes their app (without calling disconnect) there is a lot of errors on the server, but apparently nothing to do. The code below is NEVER called! I’ve seen many posts on this and some claim it works, but in my experiences there is nothing to do. Clients stick around on server, just throwing a bunch of server errors. I sincerely hope somebody knows a fix for this :slight_smile:

public class MyNetworkManager : NetworkManager
{
    // called when a client disconnects
    public override void OnServerDisconnect(NetworkConnection conn)
    {
        base.OnServerDisconnect(conn);
        Debug.Log("Player disconnected!");
        NetworkServer.DestroyPlayersForConnection(conn);
    }

    // called when disconnected from a server
    public override void OnClientDisconnect(NetworkConnection conn)
    {
        base.OnClientDisconnect(conn);
        Debug.Log("Client disconnected!");                
    }

    // called when a network error occurs
    public override void OnServerError(NetworkConnection conn, int errorCode)
    {
        base.OnServerError(conn, errorCode);
        Debug.Log("Server error!");
    }

    // called when a network error occurs
    public override void OnClientError(NetworkConnection conn, int errorCode)
    {
        base.OnClientError(conn, errorCode);
        Debug.Log("Client error!");
    }
}

This is a known bug in 5.4.2 that has been fixed in 5.4.3.

Really? But when I check for updates i says I have the latest version? Is it in beta or?

Hmm. You just had to manually run the updater :slight_smile: