SignalR icon indicating copy to clipboard operation
SignalR copied to clipboard

HubConnection disconnects if it sends bad message

Open georgemckibbin opened this issue 8 years ago • 5 comments

When using the C# HubConnection, if I send a message such as:

await Connection.SendAsync("TestMethod");

If I don't have TestMethod implemented on the Hub then it disconnects. Also, if the parameters don't match then it disconnects.

I wouldn't expect it to disconnect, just to log an error.

Using SignalR 1.0.0-alpha2-final

georgemckibbin avatar Jan 03 '18 00:01 georgemckibbin

Do you have any logs from the server and client when this occurs? We definitely have tests that do exactly this and test that the connection is not terminated, so I'd like to try and track down what may be different in this case.

analogrelay avatar Jan 03 '18 01:01 analogrelay

@anurse I don't have any logs related to that, but the exception handed in on the HubConnection's Closed handler is:

Message Websocket closed with error: InternalServerError.

Target Site {Void ThrowForNonSuccess(System.Threading.Tasks.Task)}

Stack Trace

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Sockets.Client.HttpConnection.d__49.MoveNext()

I create the connection like this:

var uri = new Uri("http://localhost:50014/nodeHub");
this.Connection = new HubConnectionBuilder()
	.WithUrl(uri)
	.Build();
this.Connection.Connected += Connection_Connected;
this.Connection.Closed += Connection_Closed;

georgemckibbin avatar Jan 03 '18 02:01 georgemckibbin

I think this was fixed post alpha2. https://github.com/aspnet/SignalR/commit/18f770e937ccb21a8417090e7667b6225a22dbe8

moozzyk avatar Jan 03 '18 03:01 moozzyk

That was going to be my next suggestion :). I'm pretty sure this won't repro in Preview 1. If you want to try the latest nightly builds, you can use instructions from here: https://github.com/aspnet/Home#builds

Note: You'll need to update AspNetCore.All AND SignalR to the latest versions from that feed.

analogrelay avatar Jan 03 '18 20:01 analogrelay

@moozzyk Ah ok, I thought that might have been the case. Not a big issue for me regardless. Just thought that since not many people seem to be using the C# client it might have gone unnoticed haha.

@anurse thanks for the help!

georgemckibbin avatar Jan 03 '18 21:01 georgemckibbin