Why SignalR send calls a callback before receiving all updates

We have a signalR hub and a JavaScript client. On the client, we call the "start" method on the proxy server, which is sent to the server. The server pushes several messages to the client as they are ready, and then ends. We expect to see the sequence " Invoking ... event ... event ... event ... Invoked", but what we see is often " Invoking ... event ... event ... Invoked ... event".

This is bad, because the JavaScript code that occurs after the hub call is completed is not a reliable place to stop listening and create a final resume - if we stop listening to messages here, there is a good chance that we can lose data and show “95% complete” .

i.e.

errorsHub.invoke('start', requestData)
  .done(function() { 
    // this will lose data
    errorsHub.off('errorsUpdate');
    showFinalSummary();
    });

Without a "shutdown", the console debug message looks like this:

[14:36:23 GMT+0100 (GMT Standard Time)] SignalR: Invoking errorshub.start
[14:36:23 GMT+0100 (GMT Standard Time)] SignalR: Triggering client hub event 'errorsUpdate' on hub 'ErrorsHub'.
...
[14:36:24 GMT+0100 (GMT Standard Time)] SignalR: Invoked errorshub.start
[14:36:24 GMT+0100 (GMT Standard Time)] SignalR: Triggering client hub event 'errorsUpdate' on hub 'ErrorsHub'.

Sometimes the latest update appears shortly after "invoked", but it can be up to 6 seconds later. Often we lose the last update, sometimes we lose two.

The problem in the browser is much more common than in Chrome. We do not run a long survey because the IIS 7.5 server

If the message “Called by a call” is sent on the same channel as the updates, how can it then bypass the last update in the pipe? On the server, when we call destination.errorsUpdate(someData), is it sent and confirmed, sent or just queued for sending? If it's just queued, is there a way to reset the connection from the server to make sure the latest update is sent?

, JavaScript invoke(...).done ?

+4
1

done() , , - , , ( - , - , , ).

, , ; - showFinalSummary(), , done(), , (, , ).

:

.

+1

Source: https://habr.com/ru/post/1537721/


All Articles