Comments (4)
@facundoolano You could just call socket.connect()
instead of socket._tryReconnect()
.
from socketcluster-client.
But that would attempt reconnection right away wouldn't it? I want it to delay, then try to reconnect, then delay a bit longer, etc...
Now that I think of it, using socket._tryReconnect()
after an auth error doesn't really work either; since the error is in the login event and not in the connection, it will always succeed on the first reconnection attempt, so it's effectively the same as wrapping a socket.connect
in a setTimeout
.
I was hoping to somehow reuse the logic of exponentially increasing delays to retry the login event, but I guess that's not possible.
from socketcluster-client.
If you want to leverage SC's autoreconnect, you could pass an error status code to the disconnect method - Some of the status codes are used by SC internally but codes between 4100 and 4500 are free for your own use. So you could go (example): socket.disconnect(4400, 'reason sring or object')
- This will cause the client socket to emit an error
event but you can handle the error.code
(if it's 4400) or just ignore it.
Status codes between 4100 and 4500 basically tell SC that the connection was closed abnormally (due to reasons unknown to SC) and to try to reconnect using exponential backoff - They are 'recoverable' errors.
You can choose your own codes for various errors (Just make sure you stay within that safe range of 4100 to 4500).
from socketcluster-client.
Ok, I'm going to use that for now (it doesn't really do the exponential thing since the connection succeeds and the login fails again, but it's still better than doing a manual timeout).
Closing this.
from socketcluster-client.
Related Issues (20)
- Increases temperature on ios devices HOT 2
- TypeError: cb is not a function HOT 8
- Update release Page HOT 1
- Not able to run the client on the office-js in excel desktop HOT 2
- Subscribe method causes error in IE11 HOT 9
- TypeError: _iterator[Symbol.iterator] is not a function || For await of loop not working on Mobile (React Native) HOT 2
- Please bump version of remote socketcluster-client
- Remove gulp, and babel dependencies
- Can this client be used in non browser environment ?
- [docs] Add description about `autoReconnectOptions` option
- Unable to resolve as a es module
- Need help for implemeting a real-time chat HOT 1
- Incorrect disconnect code HOT 1
- socketcluster-client with protocol v1 HOT 1
- How to use "subscribeWildcard" instead of "subscribe" ? HOT 1
- How we add headers in socketclusterclient HOT 5
- I got TypeError: Object is not async iterable error while trying to listen to message event in React Native app
- Docs & readme incorrect on "rejectUnauthorized" HOT 3
- eventObject timeout has a timeout set when it's not expecting a response
- SyntaxError: Identifier 'global' has already been declared HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from socketcluster-client.