HubConnection disconnects if it sends bad message
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
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.
@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.
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;
I think this was fixed post alpha2. https://github.com/aspnet/SignalR/commit/18f770e937ccb21a8417090e7667b6225a22dbe8
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.
@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!