How to dispose or destroy this withAutomaticReconnect after my condition is met? No matter what I try, the method executes every time.
const connection = new signalR.HubConnectionBuilder()
.withUrl(socketServerUrl, {
withCredentials: false,
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets,
})
.withAutomaticReconnect({
nextRetryDelayInMilliseconds: ({ elapsedMilliseconds }) => {
// function content
},
})
.configureLogging(signalR.LogLevel.Information)
.build();
if (isGameSessionExpired) {
// Looking for something like that, but didn't work
connection.stop();
connection.withAutomaticReconnect(null);
connection = null;
}
It's important to note that once a
connectionis declared asconst, it can't be reassigned tonull.And I just optimized the code and everything works fine with me, you can try it.