How to determine server disconnection from SignalR client?

前端 未结 6 803
Happy的楠姐
Happy的楠姐 2020-12-28 14:45

The question is how can SignalR JavaScript client detect when connection with server is lost?

Thanks for any reply!

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-28 14:55

    The below, worked for me:

    var connection = $.hubConnection('signalrConnectionUrl');
    
    connection.disconnected(function() {
        console.log('Connection disconnected');
    });
    

    I'm using version: 2.1.2

    See the following link for reference: Link

提交回复
热议问题