We have a signalR hub and JavaScript client. when state is changes from connected to disconnected or any state,then callback function hits more time,according to number of previous connections, here is my code:
var promise = new Promise<SignalR.ConnectionStates>((resolve, reject) => {
$.connection.hub.url =BASE_URL!;
$.connection.hub.logging = process.env.REACT_APP_CONSOLE_LOGS == "true";
$.connection.hub
.start({
transport: ["webSockets", "longPolling"],
jsonp: true,
xdomain: true,
waitForPageLoad: false,
} as any)
.done(() => {
resolve($.connection.connectionState);
this.SubscribeBreakAlerts();
})
.fail(() => reject("Could not connect"));
});
await promise;
$.connection.hub.stateChanged((e) => this.stateChanged(e));
$.connection.hub.connectionSlow(() => this.connectionSlow());
i need to find the solution of this issue