Comments (5)
I have exactly the same issue with Twitch PubSub.
RWS: handleClose { shouldRetry: true }
RWS: retries count: 1
RWS: handleClose - reconnectDelay: 2125.6480950789783
RWS: connect
RWS: bypass properties
RWS: timeout
Edit: Looks like i've found the Culprit. In the connect function, a handler for 'close' is created which calls the handleClose
function, which then tries to reconnect by calling connect
after a delay. The issue is that the connect
function has a timeout delay which does not try to reconnect upon timeout, thus it stalls. Lemme whip up a fix.
from reconnecting-websocket.
Happy to hear that!
ReconnectingWebsocket
uses the standard WebSocket API
you can use .addEventListener
or assign a function to onopen
:
rws.onopen = () => console.log('open');
from reconnecting-websocket.
Please, don't use ws
as Websocket constructor. Use the wrapper module html5-websocket
as documented in the README: https://github.com/pladaria/reconnecting-websocket#using-alternative-constructor
The way ws
frees resources seems to be incompatible with this library. This may change in the future, I'm planning a full rewrite.
from reconnecting-websocket.
Just wanted to note that using Html5WebSocket isn't a drop-in replacement for WebSocket. Neither .on('open')
, nor .onopen
works.
const ReconnectingWebSocket = require('reconnecting-websocket');
const rws = new ReconnectingWebSocket('wss://ws-feed.gdax.com', [], {
constructor: Html5WebSocket,
debug: true,
});
rws.onopen(() => { // <-- TypeError: rws.onopen is not a function
rws.send(JSON.stringify({
type: 'subscribe',
product_ids: ['BTC-USD'],
channels: ['matches'],
}));
});
I had to convert my code to use .addEventListener
.
However, the connection to GDAX now does reconnect automatically, so thanks for the module! 🙌
from reconnecting-websocket.
The URL posted above appears to no longer have a section on alternate constructors: https://github.com/pladaria/reconnecting-websocket#using-alternative-constructor Can you provide guidance on the best constructor for serverside usage in node.js?
from reconnecting-websocket.
Related Issues (20)
- removeEventListener does not seem to do anything
- close(code, reason) A parameter or an operation is not supported by the underlying object HOT 1
- Support for Dynamic Protocols
- Prevented reconnect HOT 7
- Old websockets do not seem to be terminated HOT 5
- Dequeue Events from send
- does not support http headers HOT 4
- How to use "ws.once" with this library?
- Update this._url on a preexisting ReconnectingWebSocket object HOT 1
- Seems to be broken with API Gateway Websockets HOT 2
- allow passing multiple arguments to send method
- on leave session close event not fired HOT 1
- new ReconnectingWebSocket(url).url always empty string
- WebSocket reconnection fails when using it in a React Native simulator
- WebSocket was closed before the connection was established HOT 5
- Add a user callback After the minuptime check
- I cannot close a connection HOT 2
- Use native EventTarget instead of a custom implementation
- Project abandoned? HOT 5
- This expression is not constructable 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 reconnecting-websocket.