Can a SignalR message loss be detected server side

2019-06-21 07:16发布

问题:

It seems that a SignalR server can throw away messages before they are sent to the client if its internal buffer overflows (see https://github.com/SignalR/SignalR/issues/2075). Currently we add a sequence number to all messages to let the client detect missing messages, but we would rather detect a message loss on the server and handle it there. Is that possible?

回答1:

The way SignalR handles messages is inherently asynchronous and stateless. There is no built-in mechanism for the server to detect that a message wasn't received. If you send a letter, you don't know if it got lost on the way unless you ask the recipient.

As @MEYWD pointed out in a comment, you can add this functionality if you want. If the client knows the latest sequence number it has, it can ask the server if there are any messages it hasn't received. Extending SignalR to detect this sort of thing wouldn't be difficult.



标签: signalr