本文介绍了什么时候在signalR重新连接occour?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始与SignalR工作,并试图在集线器重新连接时才能体现出来。我没有找到在网络上的任何令人满意的解释。有人可以解释,当/为什么重新连接发生?

I've started working with SignalR and was trying to figure out when a Hub Reconnect occurs. I didn't find any satisfying explanation on the web. Can someone explain when/why a reconnect occurs?

推荐答案

当有客户端离线后不久重新获得连接集线器重新连接发生。 SignalR配置值在很大程度上决定了下面的例子中的时间标记,所以不要把时间一字不差。

A hub reconnect occurs when a client goes offline then regains connectivity shortly after. SignalR configuration values largely determine the time stamps of the following examples so do not take the times verbatim.

下面是几个例子及其结果(时间格式M:SS),涉及重新连接行为:

Here are several examples and their outcomes (time format m:ss) involving reconnecting behavior:

当我提到下面我这里指的是服务器端的枢纽方法

  • OnConnected
  • OnDisconnected
  • OnReconnected

1)
0:00 - 客户端连接到服务器,OnConnected被触发
0:10 - 客户端断开连接是ISP的问题(并实现它失去连接)
0:15 - 客户端重新获得连接
0:16 - OnReconnected事件被触发

1)
0:00 - Client connects to server, OnConnected is triggered
0:10 - Client loses connection due to ISP issues (and realizes it loses connection)
0:15 - Client Regains connectivity
0:16 - OnReconnected event is triggered

2)
0:00 - 客户端连接到服务器,OnConnected被触发
0:10 - 客户端断开连接,由于拉​​动以太网电缆(不知​​道它断开)
0:15 - 客户端重新获得连接
两件事情可能发生在这里
答:0:16 - 没有任何反应和客户端继续它的previous连接
B:0:45〜 - 客户端实现其断开*
B:0:46 - 客户端过渡到重新连接状态
B:0:47 - 客户端成功地重新连接和OnReconnected事件被触发

2)
0:00 - Client connects to server, OnConnected is triggered
0:10 - Client loses connection due to pulling ethernet cable (doesn't realize it's disconnected)
0:15 - Client Regains connectivity
Two things can happen here
A: 0:16 - Nothing happens and client continues on with its previous connection
B: 0:~45 - Client Realizes its disconnected *
B: 0:46 - Client transitions into the reconnecting state
B: 0:47 - Client successfully reconnects and the OnReconnected event is triggered.

3)
0:00 - 客户端连接到服务器,OnConnected被触发
0:10 - 客户端断开连接,由于拉​​动以太网电缆(不知​​道它断开)
0:〜45 - 客户端实现其断开*
0:46 - 客户端过渡到重新连接状态
1:15 - 服务器确定客户端已经走了太久,然后忘掉它,排起了断开连接命令,在客户端接收,如果它重新连接略晚。 ***
1:15 - OnDisconnected被触发
1:16 - 客户端重新获得连接
1:17 - 客户端做了软重新连接(不触发OnReconnected)
1:18 - 客户端检索断开连接命令
1:19 - 客户端调用停止,并做了软断开(不触发OnDisconnected)

3)
0:00 - Client connects to server, OnConnected is triggered
0:10 - Client loses connection due to pulling ethernet cable (doesn't realize it's disconnected)
0:~45 - Client Realizes its disconnected *
0:46 - Client transitions into the reconnecting state
1:15 - Server determines that client has been gone for too long and then forgets about it, queuing up a "disconnect" command for the client to receive if it reconnects slightly later. ***
1:15 - OnDisconnected is triggered
1:16 - Client regains connectivity
1:17 - Client does a "soft" reconnect (does not trigger OnReconnected)
1:18 - Client retrieves the "disconnect" command
1:19 - Client calls "stop" and does a soft disconnect (does not trigger OnDisconnected)

4)
0:00 - 客户端连接到服务器,OnConnected被触发
0:10 - 客户端断开连接,由于拉​​动以太网电缆(不知​​道它断开)
0:〜45 - 客户端实现其断开*
0:46 - 客户端过渡到重新连接状态
1:15 - 服务器确定客户端已经走了太久,然后忘掉它,排起了断开连接命令,在客户端接收,如果它重新连接略晚。 ***
1:15 - OnDisconnected被触发
1:30 - 客户端停止尝试重新连接(一直试图太长)**
1:30 - 客户端转换到断开状态

4)
0:00 - Client connects to server, OnConnected is triggered
0:10 - Client loses connection due to pulling ethernet cable (doesn't realize it's disconnected)
0:~45 - Client Realizes its disconnected *
0:46 - Client transitions into the reconnecting state
1:15 - Server determines that client has been gone for too long and then forgets about it, queuing up a "disconnect" command for the client to receive if it reconnects slightly later. ***
1:15 - OnDisconnected is triggered
1:30 - Client stops trying to reconnect (been trying too long) **
1:30 - Client transitions into disconnected state

*由于客户端永葆检查:用来确定当客户端离线由于缺乏保持有效指示的。不用于长轮询传输

* Due to client side keep alive check: Used to determine when a client is offline due to lack of keep alives. Not utilized for the long polling transport

**由于客户端断开连接超时:用来确定当客户端已重新连接太长的时间和机会是在时间服务器已经忘记了客户端

** Due to client side disconnect timeout: Used to determine when a client has been reconnecting for too long of a period and chances are the server has forgotten about the client during the time

***由于服务器断开连接超时:用来确定当客户端应该被遗忘的。这是一个时间跨度开始累积,一旦连接被​​标记为死在服务器上。最终,服务器队列客户端的话题断开命令,它告诉客户端(如果它重新连接),它需要开始一个新的连接。该命令将从服务器时消失的话题被清除。

*** Due to server disconnect timeout: Used to determine when a client should be forgotten about. It's a time span that starts accruing once a connection is tagged as dead on the server. Ultimately the server queues a disconnect command for the client's topic which tells the client (if it reconnects) that it needs to start a fresh connection. The command will disappear from the server when the topic is cleaned up.

希望这有助于!

这篇关于什么时候在signalR重新连接occour?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 22:08