For JS client multiple connections, when server process restart webSockets and SSE transports only one connection raise reconnect and work, other connections not raise reconnect and not work #1243

Closed
Xiaohongt opened this Issue Jan 5, 2013 · 3 comments

Comments

Projects
None yet
5 participants
Contributor

Xiaohongt commented Jan 5, 2013

For JS client multiple connections, when server reset, webSockets and SSE transports only one connection raise reconnect and work, other connections not raise reconnect and not work.

Note, this issue just repro on webSockets and SSE transports, not repro on foreverFrame and LP transports

Repro:
1.You can download the repro issue#1243_Repro.zip for persistent connection from below:
https://skydrive.live.com/redir?resid=7230A11E3A3E316B!455&authkey=!AGdn9zKIQV1e2EA
2. map the repro to IIS website
3. request page Raw/Connections_3.html for 3 connections , Raw/Connections_2.html for 2 connections, use webSockets or SSE transport, you can specify in querystring e.g. transport=serverSentEvents, click "broadcast" button to see each connection work
4. run iisreset

you can see only one connection raise reconnect, the other connections not raise reconnect and not work, you can click "broadcast" button for the connections to test etc.

e.g. in webSockets transport, this is caused by the condition "if (this.ID === that.currentSocketID) " in connection.socket.onclose which need update , similar cause in SSE transport

            connection.socket.onclose = function (event) {
                // Only handle a socket close if the close is from the current socket.
                // Sometimes on disconnect the server will push down an onclose event
                // to an expired socket.
                if (this.ID === that.currentSocketID) {
                    if (!opened) {
                        if (onFailed) {
                            onFailed();
                        }
                        else if (reconnecting) {
                            that.reconnect(connection);
                        }
                        return;
                    }
                    else if (typeof event.wasClean !== "undefined" && event.wasClean === false) {
                        // Ideally this would use the websocket.onerror handler (rather than checking wasClean in onclose) but
                        // I found in some circumstances Chrome won't call onerror. This implementation seems to work on all browsers.
                        $(connection).triggerHandler(events.onError, [event.reason]);
                        connection.log("Unclean disconnect from websocket." + event.reason);
                    }
                    else {
                        connection.log("Websocket closed");
                    }

                    that.reconnect(connection);
                }
            };

here are some repro client logging for 2 connections:
[02:36:45 PST] SignalR: Negotiating with '../raw-connection/negotiate'.
[02:36:45 PST] SignalR: Negotiating with '../raw2/negotiate'.
[02:36:45 PST] SignalR: Connecting to websocket endpoint 'ws://localhost/Repro/raw-connection/connect?transport=webSockets&connectionId=2ca3d213-e4c2-48f0-bede-1caac9b617a0&tid=7'
[02:36:45 PST] SignalR: Connecting to websocket endpoint 'ws://localhost/Repro/raw2/connect?transport=webSockets&connectionId=415fe3ff-4790-43df-9313-f03d93559a89&tid=0'
[02:36:45 PST] SignalR: Websocket opened
[02:36:45 PST] SignalR: Now monitoring keep alive with a warning timeout of 40000 and a connection lost timeout of 60000
[02:36:45 PST] SignalR: Websocket opened
[02:36:45 PST] SignalR: Tried to monitor keep alive but it's already being monitored
SCRIPT12030: WebSocket Error: Network Error 12030, The connection with the server was terminated abnormally

SCRIPT12030: WebSocket Error: Network Error 12030, The connection with the server was terminated abnormally

[02:36:52 PST] SignalR: Unclean disconnect from websocket.
[02:36:54 PST] SignalR: Closing the Websocket
[02:36:54 PST] SignalR: Websocket reconnecting
[02:36:54 PST] SignalR: Connecting to websocket endpoint 'ws://localhost/Repro/raw2?transport=webSockets&connectionId=415fe3ff-4790-43df-9313-f03d93559a89&messageId=B%2C1%7CH%2C0%7CI%2C0&tid=8'
SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status code 503, Service Unavailable
[02:36:56 PST] SignalR: Closing the Websocket
[02:36:56 PST] SignalR: Websocket reconnecting
[02:36:56 PST] SignalR: Connecting to websocket endpoint 'ws://localhost/Repro/raw2?transport=webSockets&connectionId=415fe3ff-4790-43df-9313-f03d93559a89&messageId=B%2C1%7CH%2C0%7CI%2C0&tid=5'
SCRIPT12008: WebSocket Error: Incorrect HTTP response. Status code 503, Service Unavailable
[02:36:58 PST] SignalR: Closing the Websocket
[02:36:58 PST] SignalR: Websocket reconnecting
[02:36:58 PST] SignalR: Connecting to websocket endpoint 'ws://localhost/Repro/raw2?transport=webSockets&connectionId=415fe3ff-4790-43df-9313-f03d93559a89&messageId=B%2C1%7CH%2C0%7CI%2C0&tid=7'
[02:37:00 PST] SignalR: Websocket opened

Owner

davidfowl commented Jan 7, 2013

Moving this to RTM as it doesn't look like a regression.

@ghost ghost assigned halter73 and NTaylorMullen Jan 9, 2013

Owner

DamianEdwards commented Jan 11, 2013

@NTaylorMullen we're moving this to the backlog so you can stop working on it for now

@ghost ghost assigned halter73 Feb 12, 2013

halter73 added a commit that referenced this issue Feb 13, 2013

Allow multiple connections to simultaneously reconnect
- This affects the webSockets and serverSentEvents transports

#1243

halter73 added a commit that referenced this issue Mar 12, 2013

Allow multiple connections to simultaneously reconnect
- This affects the webSockets and serverSentEvents transports

#1243

halter73 added a commit that referenced this issue Mar 12, 2013

Updates to #1243 fix
- Moved reconnectTimeout from connection to connection._
- Moved logic to clear the reconnectTimeout to transports._logic
- Clear reconnectTimeout on transport.stop
- Clear reconnectTimeout after it fires
- Don't create reconnectTimeout if not connected or timeout already exists
- Included combined and modified JS files

halter73 added a commit that referenced this issue Mar 12, 2013

halter73 added a commit that referenced this issue Mar 12, 2013

Allow multiple connections to simultaneously reconnect
- This affects the webSockets and serverSentEvents transports

#1243

halter73 added a commit that referenced this issue Mar 12, 2013

Updates to #1243 fix
- Moved reconnectTimeout from connection to connection._
- Moved logic to clear the reconnectTimeout to transports._logic
- Clear reconnectTimeout on transport.stop
- Clear reconnectTimeout after it fires
- Don't create reconnectTimeout if not connected or timeout already exists
- Included combined and modified JS files

halter73 added a commit that referenced this issue Mar 12, 2013

halter73 added a commit that referenced this issue Mar 12, 2013

More #1243 related fixes
- Added more comments
- Moved reconnect logic shared by webSockets and serverSentEvents to
  transports.common.js
- Reconnect network before stopping connections in case of test timeout

@ghost ghost assigned Xiaohongt Mar 16, 2013

Contributor

Xiaohongt commented Mar 18, 2013

verified

@Xiaohongt Xiaohongt closed this Mar 18, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment