pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.23k stars 199 forks source link

Connect / Reconnect error handling #134

Open hernyo opened 4 years ago

hernyo commented 4 years ago

When connecting / reconnecting the urlProvider method is called and the returned string is used as the url for the new connection. However if the client is offline and urlProvider actually needs to request a new connection string for every new connection, it might fail and these errors are not handled.

Similarly the WebSocket connection throws an error if an invalid connection string is return from urlProvider.

Would be great if the library would attempt a regular reconnect in case of these errors.

Use case: connection url is unique and expires after a X minutes; the url needs to be requested every time before reconnecting.