I am using signalr 0.4 on an aspx-Page,
var hub = $.connection.FooHub; hub.disconnected(function () { log("Server has disconnected"); }); hub.ShowInfo = function (Info) { .... } $("#Button1").click(function () { hub.FooFunction('foo'); }); $.connection.hub.start();
A hub is defined as:
public class FooHub : Hub, IDisconnect { ~FooHub() { log.Debug("FooHub Destroy"); } public FooHub() { log.Debug("FooHub Startup"); } public bool FooFunction(string stuff) { log.Debug("Hub FooFunction"); Clients.ShowInfo(someInfo); return true; } public Task Disconnect() {
When I open the page and immediately click Button1
it calls the hub, which in turn calls the ShowInfo function on the page.
With Firebug, I see that signalr uses lengthy polling for switching. So, everything works as expected.
But when I wait a couple of minutes
I see that
- FooHub destroyed
- The shutdown is called in the hub,
however, there is no new connection on the page
Firebug shows an old one that is still running
and when I then click -
- FooFunction is called (I see a new connection in firebug)
- Created by FooHub
- FooFunction is executed in the hub (there is a line in the log)
- but showinfo fails
Is this a bug in SignalR or do I need to do something else to get a ShowInfo call?
Update (possible answer):
He used Forever-Frame and not a lengthy survey.
In addition, the problem seems to occur most often when using the mobile Internet (usb-stick) and Firefox.
Changing the migration to long-polling seems to fix this problem.
Nenad source share