Unable to send message to SignalR client in Azure after redeploy -


i have made few simple modifications mvc-chat sample application , have deployed azure running on 2 webworker-instances. clients can talk other clients on same instance, solved using backplane later.

when deploy new code server (from visual studio), instances upgraded 1 one, , clients reconnected first instance 2 (while instance 1 gets new code), , clients reconnected instance 1 while instance 2 upgraded. (i not changing code, re-deploying).

the problem is: after clients have reconnected, of them not able receive messages sent them, receive broadcasts.

here hub code:

public class chathub : hub {     private string getroleid()     {         return roleenvironment.currentroleinstance.id;     }      public override task onconnected()     {         string message = string.format("onconnected ({0}) {1} - version: {2}", getroleid(), context.connectionid, system.reflection.assembly.getexecutingassembly().getname().version);         clients.all.newmessage(message);         return base.onconnected();     }      public override task ondisconnected()     {         clients.all.newmessage(string.format("ondisconnected ({0}) {1} - version: {2}", getroleid(), context.connectionid, system.reflection.assembly.getexecutingassembly().getname().version));         return base.ondisconnected();     }      public override task onreconnected()     {         clients.all.newmessage(string.format("onreconnected ({0}) {1} - version: {2}", getroleid(), context.connectionid, system.reflection.assembly.getexecutingassembly().getname().version));         return base.onreconnected();     }      public void sendtoconnection(string connectionid, string message)     {         clients.client(connectionid).newmessage(message);     } } 

my index.cshtml file simple , has few modifications:

@{     viewbag.title = "index"; } <script src="~/scripts/jquery-1.8.2.js"></script> <script src="~/scripts/jquery.signalr-1.1.3.js"></script> <script src="~/signalr/hubs"></script> <script type="text/javascript"> $(function () {     var addmessage = function(message) {         var time = new date();         $('#info').prepend('<li>' + time.toutcstring() + ' - ' + message + '</li>');     };      var chat = $.connection.chathub;      chat.client.newmessage = function (message) {         addmessage('incomming message: ' + $.connection.hub.transport.name + ' - ' + message);     };      var start = function () {         $.connection.hub.logging = true;         addmessage('before start');         $.connection.hub.start().done(function () {             addmessage('after start');         });     };      $.connection.hub.statechanged(function (state) {         addmessage('state changed (' + state.newstate + '). id: <b>' + $.connection.hub.id + '</b></li>');     });     start(); });  </script>  <div id="info"></div> 

to send private message in browser (i use chrome) yourself, type in developer console:

$.connection.chathub.server.sendtoconnection($.connection.hub.id, '<b>hey!</b>') 

the "hey" not appear in 5-15% of browsers.

this showing on javascript console window when browser gets "blinded" reconnected server:

[15:25:08 gmt+0200 (w. europe daylight time)] signalr: keep alive has been missed, connection may dead/slow. jquery.signalr-1.1.3.js:54 [15:25:14 gmt+0200 (w. europe daylight time)] signalr: keep alive timed out.  notifying transport connection has been lost. jquery.signalr-1.1.3.js:54 [15:25:16 gmt+0200 (w. europe daylight time)] signalr: closing websocket jquery.signalr-1.1.3.js:54 [15:25:16 gmt+0200 (w. europe daylight time)] signalr: clearing hub invocation callbacks error: connection started reconnecting before invocation result received. jquery.signalr-1.1.3.js:54 [15:25:16 gmt+0200 (w. europe daylight time)] signalr: websockets reconnecting jquery.signalr-1.1.3.js:54 [15:25:16 gmt+0200 (w. europe daylight time)] signalr: connecting websocket endpoint 'ws://myappname.cloudapp.net/signalr/reconnect?transport=websockets&connectiontoken=z-auixxw_jcbhdi631xcvrrqlomtk0jvl3l-drycesu01cvkgdzwpfc8glhk2p9zlmp-4glwxlydkzduji-vahn0qoglenc2z85p8ecdt1fgtbli0&connectiondata=%5b%7b%22name%22%3a%22chathub%22%7d%5d&messageid=b%2c14&tid=3' jquery.signalr-1.1.3.js:54 [15:25:25 gmt+0200 (w. europe daylight time)] signalr: websocket opened jquery.signalr-1.1.3.js:54 [15:25:25 gmt+0200 (w. europe daylight time)] signalr: triggering client hub event 'newmessage' on hub 'chathub'. jquery.signalr-1.1.3.js:54 [15:25:25 gmt+0200 (w. europe daylight time)] signalr: triggering client hub event 'newmessage' on hub 'chathub'. jquery.signalr-1.1.3.js:54  > $.connection.chathub.server.sendtoconnection($.connection.hub.id, '<b>hey!</b>') object {state: function, always: function, then: function, promise: function, pipe: function…} 

any on solving bug appreciated.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -