Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR Broadcast Messages Duplicated after Stop/Start

Messages sent to the client by the hub are replicated for each time I have stop/started the connection.

If I execute this sequence: $.connection.hub.stop() $.connection.hub.start() {...}

and send a message from the server hub to the client, the message is received one time. If I reexecute the above sequence, I will received the same message twice, even though the server hub calls Clients.Client(Context.ConnectionId).acceptMsg(msg); only 1 time. acceptMsg is invoked twice at the client for the same message with the connectionId. I get the same results using Clients.All.acceptMsg(msg)

For each subsequent stop/start, the message is further duplicated; three messages the third time, four messages the fourth, etc.

I have tried separating invocation of the stop and start by a couple of minutes but it made no difference.

Other details: Javascript client, SignalR v2.0.1, Chrome Version 31.0.1650.63, ASP.Net 4.5. SignalR is utilizing long-polling in my test and I am allowing the default negotiation. In the SignalR trace, "SignalR: Aborted xhr request." is observed after the stop, before the start.

Any idea what is causing my messages to be replicated in this scenario?

like image 866
codezoo Avatar asked Jan 07 '14 16:01

codezoo


People also ask

How long do SignalR connections stay open?

The default keepalive timeout period is currently 20 seconds. If your client code tries to call a Hub method while SignalR is in reconnecting mode, SignalR will try to send the command. Most of the time, such attempts will fail, but in some circumstances they might succeed.

Does SignalR guarantee delivery?

SignalR doesn't guarantee message delivery. Since SignalR doesn't block when you call client methods, you can invoke client methods very quickly as you've discovered. Unfortunately, the client might not always be ready to receive messages immediately once you send them, so SignalR has to buffer messages.

Is SignalR bidirectional?

ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available.


1 Answers

This is a known issue and has been fixed in the coming 2.0.2 release. Here's the GitHub issue for reference: https://github.com/SignalR/SignalR/issues/2595

like image 194
N. Taylor Mullen Avatar answered Sep 29 '22 15:09

N. Taylor Mullen