NetworkClient.RegisterHandler not working

I’m trying to handle the networking errors, but RegisterHandler apparently is just being ignored.
I.e. I call it, and it is exactly as if I didn’t: I still get the default error handling.

This is my OnStartClient:

        public override void OnStartClient (NetworkClient client)
        {
            Debug.Log("Starting client: "+client);

            client.RegisterHandler(MsgType.Error, (NetworkMessage msg)=>{
                Debug.Log("Client error: "+msg);
            });
            client.RegisterHandler(MsgType.Disconnect, (NetworkMessage msg)=>{
                Debug.Log("Client disconect: "+msg);
            });
            client.RegisterHandler(MsgType.Connect, (NetworkMessage msg)=>{
                Debug.Log("client connect"+msg);
            });

            base.OnStartClient(client);
        }

• I start the server
• I connect the client to the server
• I quit the server
• the client gets a standard timeout error, instead of being handled

What am I doing wrong?

Meanwhile I’ve noticed I can just ignore the RegisterHandler and instead override a few functions in the NetworkManager:

		public override void OnClientError (NetworkConnection conn, int errorCode)
		{
			Debug.Log("Client error #"+errorCode+" on "+conn);
		}

Which would be nice, but it still doesn’t suppress the standard error. How do I make that go away? No, just unchecking “Error Pause” is very obviously not an answer.

calling RegisterHandler is replacing the NetworkManager’s internal handlers. Use the virtual functions instead

Which functions?

listed on this page:

http://docs.unity3d.com/Manual/UNetManager.html

Like the OnClientError I already posted above?

Didn’t work, as I explained. It gets called, but the standard error still gets thrown anyway.

Or am I missing something else?

Guys, seriously.

UNet Client Disconnect Error: Timeout
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

How do I trap this message?

No matter what I do, I will still receive the error, too. Why?

As you can see it’s a client disconnection. Try OnClientDisconnect().

Both OnClientDisconnect and OnClientError get called.
But I still receive the error too.

2391453--162935--Screen Shot 2015-11-22 at 00.40.43.png

		public override void OnClientError (NetworkConnection conn, int errorCode)
		{
			LogManager.Log("Client error #"+errorCode+" on "+conn);
		}
		public override void OnClientDisconnect (NetworkConnection conn)
		{
			LogManager.Log("Connection reset by peer (cit.).");
		}
		public override void OnClientNotReady (NetworkConnection conn)
		{
			LogManager.Log("Client not ready?");
		}

That error is supposed to be there. It will tell you that the client has disconnected. Nothing you can do about it to prevent it from outputting the log message.

If you still think it is annoying, turn off “Show Log Error Messages” in the Console tab.

If you still think that is not helpful, ask @seanr .

Oh?

Errors should always be trappable. Always.

If I handle them personally, I… handle them personally. If they get thrown anyway ignoring my own handler, what’s the point of having a handler in the first place?

This is wrong :frowning:

LogFilter.current = (LogFilter.FilterLevel)5;