HttpClientException when connecting to working hub from SignalR .NET Client
@Michael Tiller's comment in @Darren's answer turned out to be the solution for my problem, so I think it's fair to make this into its own answer:
Changing the Hub class to public
solved my problem. I followed an example and missed the text that said to create a PUBLIC class that inherits from Hub
, and when adding a new class in Visual Studio, by default it creates it as
class TestHub
{
}
...which is technically internal
(see here). More careful reading on my part would have prevented this, but in case someone else got in too big of a hurry like I did... :)
Real issue was resolved but i think it's important to realise that SignalR server returning status 500 (Internal Server Error) (not very informative error indeed) is security feature.
If you need more information on server errors, you can do following:
1) Enable tracing on server
and\or
2) Enable detailed exception messages send to client (don't do that in production!):
SignalR 1.x:
RouteTable.Routes.MapHubs(new HubConfiguration { EnableDetailedErrors = true });
SignalR 2.x
public void Configuration(IAppBuilder app)
{
var hubConfiguration = new HubConfiguration
{
#if DEBUG
EnableDetailedErrors = true
#else
EnableDetailedErrors = false
#endif
};
app.MapSignalR(hubConfiguration);
}
This turned out to be a trivial mistake, but the error message was so useless I'm sure others will be stumped by the same issue. The name of the hub was wrong. I used "Chat" when I should have used "ChatHub".
If the exception had been 404, or "Hub not found" or something like that it would have been an easy fix rather than a couple of wasted hours!