'SignalR (ASP .Net) not attempting to connect when client calls .start()
I am using signalr for asp .net
My client does not attempt to connect when I call connector.start(); (I see no network calls being made and a breakpoint I set in my Hub class OnConnected method does not get hit).
If however I switch to a different tab in the browser which causes the signalr client to disconnect and reconnect, then the client does connect (see my callback attached to the disconnected method below).
Why is it not connecting the first time?
Edit: If I replace connector.start() with connector.stop() to force it to reconnect in the disconnected callback, it works.
const hub = (window as any).jQuery.connection.myHub;
if (hub) {
hub.client.myClientMethod = myClientMethod;
const connector = (window as any).jQuery.connection.hub;
if (authCode) {
connector.qs = { 'authToken': authCode };
}
connector.disconnected(() => {
connector.start();
});
connector.start(); // this doesn't do anything
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
