I've got a few questions and problems regarding SignalR.
1st question:
I've downloaded signalr like this: npm install @aspnet/signalr
according to Npmjs (v1.0.3).
However, upon further inspection, my signalr files do not contain reconnect-functionality as can be found on the github:343 here.
As a matter of fact, it seems like these are two different repos. Why do they differ, both seem to be developed by microsoft?
these are the two repos: https://github.com/SignalR/SignalR and https://github.com/aspnet/SignalR
2nd question:
I've tried to implement reconnect-functionality into my application with the limited functionality avaliable to me. This is my current approach (since i lack the reconnect-functions in the 1st repo) the code below produces this output on disconnect:
signalr.min.js:1353 Error: Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server.'.
Uncaught TypeError: this.connect is not a function
at HubConnection.eval
trying to connect...
Uncaught TypeError: this.connect is not a function
at HubConnection.eval
trying to connect...
etc... etc...
Code:
this.connection.onclose(function (error) {
if (!this.isConnected) {
this.isConnected = false;
appService.emit("disconnected", true);
var intervalFunc = setInterval(function () {
console.log("trying to connect...");
this.connect();
if (this.isConnected) {
this.appService.emit("connected", true);
this.isConnected = true;
clearInterval(intervalFunc);
console.log("connection established");
}
}.bind(this), 5000);
}
});
I've also followed these resources in trying to implement reconnect-functionality:
- https://stackoverflow.com/a/23407156/2902996
- https://learn.microsoft.com/en-us/aspnet/signalr/overview/guide-to-the-api/handling-connection-lifetime-events#how-to-continuously-reconnect
- https://github.com/davidfowl/UT3/blob/dac409886c1bb7aec7c150b74d4ce9a3e246f03c/UTT/wwwroot/js/utt.js#L141-L153
- https://github.com/aspnet/Docs/issues/6757
Any help would be greatly appreciated.