Comments (3)
I've figured out that I'm not getting ECONNREFUSED from the connection attempt, so that is clearly the issue. Not really a problem when things go to production and the backend is long-running, but in development that's going to be a hassle.
I suppose I could just manually trigger a reconnect to workaround this for the moment. E: Nevermind, it doesn't attempt to reconnect even when triggering it manually, as it still thinks it's hit the maximum number of attempts already.
E2: After further tinkering (read: editing dependencies manually) and manually attempting a reconnect, it seems that the current number of attempts is undefined inside the library's own onreconnect
handler, then becomes NaN. Left is num
, right is maxAttempts
:
This makes sense, as the connection is never opened, so onopen
is not called, and so num
is never initialized to 0. Can confirm that initializing num
to 0 allows for this workflow.
from sockette.
IMO, this makes sense, unless I'm missing something here?
You can only re-connect after having connected in the first place.
Initializing num=0
at the start would fix this for you, but I feel like it's encouraging lack of error handling. You should definitely be handling ECONNREFUSED
& the like manually, or kill the process. That's what the hooks are intended for, really.
It'd be much worse to (potentially) indefinitely ping your server that's shut down or choking.
What do you think?
from sockette.
Hey @sli – it looks like you edited your response after I replied, so I never saw that last portion (and was never notified)
Are you saying that the fix was to declare num=0
at the top of the constructor?
from sockette.
Related Issues (20)
- Disable reconnect programmatically HOT 15
- Access underlying socket object HOT 3
- SCRIPT5022: SecurityError in IE11 HOT 1
- onerror not returning code HOT 2
- ws.close should clear pending setTimeout HOT 1
- Still in CONNECTING state HOT 1
- Still reconnecting after close() HOT 5
- didunmount
- Bump npm version to include #48 HOT 1
- Able to detect network lost? HOT 1
- Possible to get WebSocket instance? HOT 1
- How to get error code HOT 1
- When I close the connection, it doesn't send queryStringParameters HOT 1
- Socket connection code choices HOT 2
- [Feature] Ability to set url before reconnecting HOT 1
- Automatically split & re-combine messages over a certain size HOT 5
- Increment timeout HOT 2
- Sockette.close can unexpectedly clear other timeouts/intervals
- project status? HOT 2
- Put an option to always reconnect, no matter what
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 sockette.