La detención de la conexión SignalR es lenta
Frecuentes
Visto 4,021 equipos
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?
3 Respuestas
2
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
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.
Respondido 08 Abr '14, 06:04
0
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 asp.net signalr or haz tu propia pregunta.
Para referencia : github.com/SignalR/SignalR/issues/2653 - Jason Evans
@Jason Evans, thanks for reference, but I think that it is not my case, because my problem related with Javascript-clients, (not .NET clients). - Ainullin Damir
Is it that slow even when you only have 1-2 clients? - Abhishek Nanda
@Abhishek Nanda, yes. - Ainullin Damir
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