2

I build a cordova app that use socket io. On ios, when the phone enter in standby I am losing the socket connection. How can I detect that and reconnect the socket connection automatically?

Raphael Boukara
  • 398
  • 3
  • 11
  • Here is a similar problem to yours http://stackoverflow.com/questions/9708604/nodejs-socket-io-connections-dropping-reconnecting – Jroosterman Dec 31 '14 at 18:48
  • I don't think it is similar because that's not depend on idle time, if push the standby button on the phone, the phone enter directly in stand by and i am losing the connection – Raphael Boukara Dec 31 '14 at 19:08
  • Yeah, looking around this is a problem that they are dealing with. They had some potentially successful results using TCP when using VOIP. It is a different library but maybe it can help you out. http://stackoverflow.com/questions/6601536/ios-voip-socket-will-not-run-in-background – Jroosterman Dec 31 '14 at 19:18
  • did you ever find a solution to this @RaphaelBoukara – trickpatty Feb 19 '16 at 17:53
  • I actually just discovered some very interesting behavior that I did not expect, and it seems to solve my issue as well. Including the [cordova-background-mode](https://github.com/katzer/cordova-plugin-background-mode) plugin and enabling it keeps my socket connection open. handling other functions and events in my app shouldn't be a problem, the problem was just keeping the socket connection open. all I had to do was enable the background mode with cordova.plugins.backgroundMode.enable() and it works, I didn't even have to set functions to run in the onactivate event. – trickpatty Feb 19 '16 at 20:33

0 Answers0