fail callback not invoked during send #404

Closed
enriko-riba opened this Issue May 20, 2012 · 3 comments

2 participants

@enriko-riba

The signalR.send prototype function is throwing instead invoking the fail callback if transport is null.
Also the message 'SignalR: Connection must be started before data can be sent. Call .start() before .send()' is misleading.

The fail callback is not invoked:
chatHub.sendMessage(aMessage).fail(function (e) {
console.warn(e);
});

I noticed that only after attaching the debugger to IE and when the IIS connections get starved/staled.

@davidfowl
SignalR member

Do you have repro steps?

@enriko-riba
  1. method (Win7+IIS)
  2. Server: Create minimal hub with one function e.g
    SendMessage(string message )
    {
    return Task.Factory.StartNew( () => { Clients.addMessage( message ); } );
    }

  • Client subscribe to addMessage and display the message somewhere on page
  • Client: add input + button,
  • Client: attach a click handler to button that sends text - with fail callback e.g.
    chatHub.sendMessage(aMessage).fail(function (e) {
    console.warn(e);
    });

  • Starve the IIS connections by repeatedly pressing F5 in IE

  • Attach to IE and watch the send in jquery.signalR-0.5.0.js line 222
  • try sending a message and the transport will be null causing a throw and no fail invoke

Method 2

  • same setup as above
  • start the client and wait until a timeout occurs (fix yourself a coffee and drink it). I am actually in doubt if this is another bug as IMHO there should be no time as long as the page stays open.
  • try sending a message: again no fail callback is invoked
@davidfowl
SignalR member

By design. To handle connection failure use the error handler on the hub connection. .fail() is only called when there's an error during hub invocation. To do this use:

$.connection.hub.error(function() {
    console.log('maybe the server is down');
});
@davidfowl davidfowl closed this Jul 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment