I’m encountering an issue with SignalR in a .NET 8 application
where an await action on SendAsync method seems to hang
when targeting a specific client via their connection ID.
This problem does not arise immediately but starts occurring
after about 10 minutes of continuous connection between the server and an Angular frontend.
The frontend continues to receive and handle messages without any exceptions,
but the server side await does not proceed beyond the SendAsync call after a while.
The Server and Frontend are running locally on my windows 11 computer
Server Code Example That Gets Hanged
await hub.Clients.User(<connection id>).SendAsync(<message>,<data>);
Frontend Implementation
this.connectionWebService.on(<message>, <data> => {
// Logic goes here
});
// Web service setup
const transportType = HttpTransportType.LongPolling;
const protocolWebService = new JsonHubProtocol();
this.connectionWebService = new HubConnectionBuilder()
.withUrl(this.signalRServerUrl, {
accessTokenFactory: () => this.accessToken,
transport: transportType
})
.configureLogging(LogLevel.Information)
.withHubProtocol(protocolWebService)
.build();
- The Angular application successfully receives and handles the messages.
- There are no exceptions thrown on either the server or the frontend.
What could be causing the SendAsync method to hang after a prolonged period of successful interaction?
Remark the frontend still keeps getting those messages and handles them successfully
How can I further diagnose or fix this issue without resorting to a cancellation token?