guness / node-xcs

NodeJS implementation of Google's XMPP Connection Server
BSD 2-Clause "Simplified" License
38 stars 23 forks source link

xmpp reconnect after WebSocket connection error #17

Closed RDLemos closed 7 years ago

RDLemos commented 7 years ago

Allow the XMPP Client to try to reconnect to the Server, if the WebSocket connection gets disconnected. The client will try to reconnect according to the default

guness commented 7 years ago

reconnect was causing trouble, have you checked it?

RDLemos commented 7 years ago

What kind of trouble? I have checked on our server, and was working fine. Before the change, once we lost the WS connection, we would need to restart the server. After the change, when the WS is lost, the XMPP client will try to reconnect after the time-out set (10s).

RDLemos commented 7 years ago

These are the result of my testing using the reconnect option: 1) Using reconnect option, once we get a WS error detected on the connection (Network down), the xmpp client tries to re-establish the stream: 23:49:30.681Z ERROR appIMPServer: [FCM]: Socket error [Dev Server]: { [Error: read ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'read' }

xmpp:connection use lazy socket +3s xmpp:connection setup stream +1ms xmpp:connection use lazy socket +631ms xmpp:connection setup stream +1ms xmpp:connection use lazy socket +1s xmpp:connection setup stream +1ms xmpp:connection use lazy socket +2s xmpp:connection setup stream +1ms xmpp:connection use lazy socket +1s xmpp:connection setup stream +1ms xmpp:connection use lazy socket +2s xmpp:connection setup stream +0ms

2) Once I reestablish the server connection ( network Up), the CMPP-Client reconnects the WS, and reconnect the stream:

xmpp:connection use lazy socket +24s xmpp:connection setup stream +1ms xmpp:connection send: +247ms xmpp:connection receive: +129ms xmpp:connection receive: X-OAUTH2X-GOOGLE-TOKENPLAIN</stream:features> +1ms xmpp:connection send: MjgyMjE5MzA5NzI5QGdjbS5nb29nbGVhcGlzLmNvbQAyODIyMTkzMDk3MjkAQUl6YVN5Q0lGdkN1SU5ZS1Y3RzA4aFgxVVg0OXpXUnFCVFk0ekpn +1ms xmpp:connection receive: +76ms xmpp:connection send: +0ms xmpp:connection receive: +41ms xmpp:connection receive: </stream:features> +1ms xmpp:connection send: 96C5361B +1ms xmpp:connection receive: jid>282219309729@gcm.googleapis.com/96C5361B</jid +43ms xmpp:connection send: +1ms xmpp:connection receive: +1ms xmpp:connection receive: +47ms 23:59:18.957Z INFO appIMPServer: [FCM]: Connected to FCM for Prod Server notifications

@guness : What problem did you have with reconnect?

I am waiting for this update to be able to allow some of our server users to start using our push notifications service.

RDLemos commented 7 years ago

@guness : Do you think you will be able to update the npm to version 1.6 with this change today or tomorrow?

guness commented 7 years ago

published