Why MongooseIM closes the websocket connection after 60 seconds?

530 views Asked by At

I am using MongooseIM as chat server and connecting it over websocket using xmpp.js inside react-native application. The server forcefully closes the connection after 60s on inactivity. I want to know:

  1. If this is the default config?
  2. Should/Can I change it?
  3. Should I set up ping mechanism such that my client must send some pings after every 60s to avoid disconnect
1

There are 1 answers

3
michalwski On BEST ANSWER

WebSocket connections have default timeout value for inactivity set to infinity. Your configuration most probably contains "{timeout, 60000}" in the "mod_websockets" configuration. In order to keep idle connections connected to the server you can send WebSocket ping frames from time to time.

More info about "mod_websockets" configuration is here:: https://mongooseim.readthedocs.io/en/latest/advanced-configuration/Listener-modules/#http-based-services-bosh-websocket-rest-ejabberd_cowboy

You can even configure the server to send WebSocket's ping frames by specifying the option {ping_rate, ValueInMilliSeconds}