C
C#9mo ago
Alen Alex

Unable to connect to SignalR (Not Azure SignalR) after deployment to Azure App Service

We are trying out SignalR in one of our .net 7 web API deployed in Azure. The issue is it won't allow connecting to the signalR after deployment, It was first CORS error (Even tho, CORS has been enabled in the backend) , when changed to SSE, now I am getting a 404 NOT FOUND ({ "statusCode": 404, "message": "Resource not found" }) on negotiate This is how I am connecting
ngOnInit(): void {
var hubConnection = new HubConnectionBuilder()
.withUrl("https://domain..../v1/instruments/instrumentHub", {
headers: {
"Ocp-Apim-Subscription-Key": "Dummy Data"
},
withCredentials: false,
transport: HttpTransportType.ServerSentEvents,
.configureLogging(LogLevel.Trace)
.build();

hubConnection.start().then(() => {
console.log(1)
}).catch((e) => {
console.log('error', e)
})
}
ngOnInit(): void {
var hubConnection = new HubConnectionBuilder()
.withUrl("https://domain..../v1/instruments/instrumentHub", {
headers: {
"Ocp-Apim-Subscription-Key": "Dummy Data"
},
withCredentials: false,
transport: HttpTransportType.ServerSentEvents,
.configureLogging(LogLevel.Trace)
.build();

hubConnection.start().then(() => {
console.log(1)
}).catch((e) => {
console.log('error', e)
})
}
The above code will respond with
{ "statusCode": 404, "message": "Resource not found" }
{ "statusCode": 404, "message": "Resource not found" }
If I tried with
withCredentials: false,
skipNegotiation: true,
transport: HttpTransportType.WebSockets,
withCredentials: false,
skipNegotiation: true,
transport: HttpTransportType.WebSockets,
This is what I get
[2024-04-01T05:07:51.737Z] Debug: HubConnection failed to start successfully because of error 'Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.'.
[2024-04-01T05:07:51.737Z] Debug: HubConnection failed to start successfully because of error 'Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.'.
If I don't skipNegotiation -> Then its a CORS error I have tried almost everything that I am aware of.... I have also enabled WebSockets in the App Services Configuration
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server