La detención de la conexión SignalR es lenta

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:


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?

preguntado el 14 de enero de 14 a las 17:01

@Jason Evans, thanks for reference, but I think that it is not my case, because my problem related with Javascript-clients, (not .NET clients). -

Is it that slow even when you only have 1-2 clients? -

@Abhishek Nanda, yes. -

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? -

3 Respuestas

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

Respondido el 19 de junio de 17 a las 14:06

conn = null;
hub= null;

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

Respondido 08 Abr '14, 06:04

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

Respondido 18 Abr '14, 20:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.