1

Stoping SignalR connection of Javascript client is slow (around 30 seconds).

I use SignalR, version 2.0.1 (but problem reproduced in 2.0.0 ) for webchat integrated to ASP.NET site. I have one .NET SignalR client(for other reason) and a lot of JS clients (chat clients). My test case is very simple. I want to disable chat on ASP.NET page. For this reason I try to stop SignalR connection using next code:

$.connection.hub.stop();

But onDisconnected method (on hub) was calling only after 30 seconds. I suppose that connection was stopped by disconnect timeout but not by Javascript code. I use LongPolling transpot by default.

var initObject = { transport: ["longPolling", "webSockets", "foreverFrame", "serverSentEvents"] };
$.connection.hub.start(initObject).done(function () {
    ...
}

Problem reproduce in last versions of Google Chrome but works fine in IE and Mozilla. What reason of so strange behaviour of SignalR and how can I avoid it?

9
  • 1
    For reference : github.com/SignalR/SignalR/issues/2653 Jan 14, 2014 at 19:06
  • @Jason Evans, thanks for reference, but I think that it is not my case, because my problem related with Javascript-clients, (not .NET clients). Jan 14, 2014 at 19:31
  • Is it that slow even when you only have 1-2 clients? Jan 14, 2014 at 22:37
  • @Abhishek Nanda, yes. Jan 15, 2014 at 7:44
  • Seems to me like stop() probably isn't doing its job then. If you're getting the 30 second timeout it means that the connection isn't being killed by you calling stop. Do you have a repro for this problem?
    – davidfowl
    Jan 15, 2014 at 18:31

3 Answers 3

2

For anyone else having this issue just use conn.Stop(new TimeSpan(0)) to kill the connection instantly.

0
conn.disconnect();
conn.stop();
hub.subscribe(null);
conn = null;
hub= null;

try this and let me know if it works.It works in android though.

0

The problem is solved by updating SignalR version to the 2.0.3.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.