I was working on ASP.NET Core SignalR client application to receive the message from the SignalR hub. This is the scenario where my SignalR server and client were two separate .NET Core applications. In the client application, I got the below error message while trying to receive the message from SignalR Hub(server). This error may arise and the solution is almost similar for both cases using SignalR Javascript client and .NET Client.
Exact Error Message: “Error: Failed to complete negotiation with the server: Error: Not Found: Status code ‘404’ Either this is not a SignalR endpoint or there is a proxy blocking the connection.”
Below is my earlier code:
var connection = new signalR.HubConnectionBuilder().withUrl("http://localhost:39823/event-hub)
Then to resolve the above error I found that we need to add the below code in HubConnectionBuilder.
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
Note that: The negotiation should be skipped only when the transport property is set to ‘signalR.HttpTransportType.WebSockets‘.
Solution
Below is the previous code with which I got an error.
var connection = new signalR.HubConnectionBuilder().withUrl("http://localhost:4023/yourevent)
Complete code to resolve the issue.
var connection = new signalR.HubConnectionBuilder().withUrl("http://localhost:4023/yourevent", {
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
Note: This solution is applicable for both cases either using the SignalR .NET client or SignalR JavaScript client.
I hope you have got an idea of how to resolve this error.