Skip to content

Commit 9398244

Browse files
Gourav DwivediGourav Dwivedi
authored andcommitted
added retry connection feature
1 parent b5f7a38 commit 9398244

File tree

3 files changed

+47
-37
lines changed

3 files changed

+47
-37
lines changed

package-lock.json

Lines changed: 27 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "signalr-web-client",
33
"version": "1.0.0",
4-
"description": "ASP.Net Core Signal R JavaScript Client.",
4+
"description": "ASP.Net Core SignalR Web Client.",
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
@@ -19,7 +19,7 @@
1919
},
2020
"homepage": "https://github.com/gouravdwivedi6590/SignalR-JS-Client#readme",
2121
"dependencies": {
22-
"@aspnet/signalr": "^1.1.4",
22+
"@microsoft/signalr": "^3.1.2",
2323
"@webcomponents/webcomponentsjs": "^2.2.10",
2424
"bootstrap": "^4.3.1",
2525
"jquery": "^3.4.1",

src/js/components/logic/lib/app.signalr.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as SignalR from "@aspnet/signalr";
1+
import * as SignalR from "@microsoft/signalr";
22
import { AppEvents } from './app.common';
33

44
class SignalRApp {
@@ -18,6 +18,7 @@ class SignalRApp {
1818
this.connection = new SignalR.HubConnectionBuilder()
1919
.withUrl(options.url, options)
2020
.configureLogging(SignalR.LogLevel.Information)
21+
.withAutomaticReconnect([0, 3000, 5000, 10000, 15000, 30000])
2122
.build();
2223

2324
//Receive Data
@@ -29,6 +30,22 @@ class SignalRApp {
2930
self.processResponse.call(self.connection, data);
3031
self.HandleResponse(data);
3132
}
33+
34+
self.connection.onreconnecting((error) => {
35+
// disableUi(true);
36+
// const li = document.createElement("li");
37+
// li.textContent = `Connection lost due to error "${error}". Reconnecting.`;
38+
// document.getElementById("messagesList").appendChild(li);
39+
console.log('On Reconnecting...');
40+
});
41+
42+
self.connection.onreconnected((connectionId) => {
43+
// disableUi(false);
44+
// const li = document.createElement("li");
45+
// li.textContent = `Connection reestablished. Connected.`;
46+
// document.getElementById("messagesList").appendChild(li);
47+
console.log('On Reconnected...');
48+
});
3249

3350
AppEvents.emit('Init', options);
3451
AppEvents.emit('Logger', "Init");

0 commit comments

Comments
 (0)