Closed gregscott333 closed 1 year ago
If you remove
skipNegotiation: true,
transport: HttpTransportType.WebSockets,
does it work?
If I remove those 2 lines I get the error: "Failed to complete negotiation with the server" "Failed to start the connection"
Sounds like you can't reach your endpoint. Either you have the wrong url, or you have some firewall settings that are blocking traffic.
It could be an issue with out firewalls setup in our Azure account or something else that we are missing.
Like I said before, it works fine locally so I'm assuming it's a networking issue rather than a code issue.
Those are both likely, and not something this repo is meant to diagnose. I suggest posting on stackoverflow or Azure specific forums.
Is there an existing issue for this?
Describe the bug
We have implemented a simple solution using .NET Core and Signalr to update our front-end when a task completes on the server. It works fine when running it locally on localhost but is giving the error: "(WebSockets transport) There was an error with the transport" as can be seen in dev tools below
I have gone through every link I can find on Google to no avail.
This is the front-end code for setting up Signalr in the front-end:
const newConnection = new HubConnectionBuilder() .withUrl(
${environment.apiBaseUrl}/hubs/messageHub
, { skipNegotiation: true, transport: HttpTransportType.WebSockets, }) .withAutomaticReconnect() .configureLogging(LogLevel.Trace) .build();newConnection.start().catch((e) => console.log("Connection failed: ", e));
These are the relevant bits from the Program.cs file on the server:
builder.Services.AddSignalR();
app .UseHttpsRedirection() .UseRouting() .UseAuthentication() .UseAuthorization() .UseCors( x => x .AllowAnyMethod() .AllowAnyHeader() .SetIsOriginAllowed(_ => true) // allow any origin .AllowCredentials()) // allow credentials // register module-specific middleware - start .UseUserManagementModuleMiddleware() .UseWorkflowEngineModuleMiddleware() .UseRequestsModuleMiddleware() .UseTasksModuleMiddleware() // register module-specific middleware - end .UseMiddleware()
.UseMiddleware()
.UseEndpoints(
endpoints =>
{
endpoints.MapControllers();
endpoints.MapHealthChecks("health");
}
);
app.MapHub("hubs/messageHub");
The front-end and API are both being hosted on Azure. The front-end as a static website and the API as an app service. I managed to update the web sockets setting on the app service to true using the Azure CLI but unfortunately that didn't work either. It could be an issue with out firewalls setup in our Azure account or something else that we are missing.
Like I said before, it works fine locally so I'm assuming it's a networking issue rather than a code issue.
Expected Behavior
A successful connection to be created between the front-end and the backend as shown below:
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
.NET 6
Anything else?
@microsoft/signalr": "^7.0.5