I have an Angular client which uses signalR library "@aspnet/signalr": "^1.1.4"
I need it just to receive notifications from ASP.net server. So I build and start hubConnection which is
private hubConnection: signalR.HubConnection;
and then subscribe on different messages from server
this.hubConnection.on("SomeMessage", (data: MyDto) =>
myActions()
);
All works fine and receives messages but after several hours of work something happens (with network I suppose) and on server fires method
public override async Task OnDisconnectedAsync(Exception e)
That is fine, but I want to handle disconnections on client's side. I read this and this and many more answers but my hubConnection
has neiter disconnect
method nor hub
property which are mentioned in those answers. So I would appreciate any hints where they could be. Preferable in typescript, not in html.
UPDATED
Well, as was proposed I changed signalR package to "@microsoft/signalr": "^5.0.4"
by I still can't find onDisconnect
event
There is an instance of signalR.HubConnection
which I build as shown below
private buildConnection(url: string, token: string) {
this.hubConnection = new signalR.HubConnectionBuilder()
.withUrl(url, { accessTokenFactory: () => token })
.build();
}
But this instance does not have onDisconnect event.