Comments (1)
tl;dr
I have not quite wrapped my head around this one, but can it be possible that the hybi Socket
object emits a readyState open
, although the connection is actually already closed again?
some details
In order to visualize the whole procedure, I drew a callgraph, (handleUpgrade.dot.png)[https://github.com/ruxkor/engine.io/blob/master/docs/handleUpgrade.dot.png].
A small legend:
- blue, dashed: synchronos process flow
- blue, dashed: async process flow
- green, solid: place where a function is constructed, and also called, if there is no other green, dashed arrow
- green, dashed: where the function is called
- red, dashed: assumed order if the asynchronous functions
combining the blue, solid arrow with the red, dashed arrows should present the actual flow of engine.handleUpgrade
.
Back to the problem:
In ws.Websocket.establishConnection
the object sets its own readyState
on OPEN
, after attaching the first and dataHandler to be called on process.nextTick
and socket.on('data')
respectively. It also attaches cleanupWebSocketResorces
to its socket object. Only then it emits 'open'
,
Only then the w.io.hybi.WebSocket.onOpen (fn 1)
will be called, which in turn attaches a function to process.nextTick
, that will set the Sockets readyState on open and emit 'open'
.
If a socket gets cleaned up, because of a sudden disconnect, I think the w.io.hybi.WebSocket (fn 1.1)
will still be called, since it was already attached to process.nextTick.
possible solution
One possibility would be to check the readyState
of the ws
object inside (fn 1.1)
, and only set its own readyState and emit if it equals WebSocket.OPEN
, similiar how the firstHandler
is doing it in establishConnection
.
An imo even better solution would be to implement getters and setters for the websocket.io.WebSocket
readyState
. In this way, it would be trivial to return th actual readyState
, i.e. the one of the ws
object, but still using an own attribute for the drafts.js WebSocket (since there is no ws
attribute to use here).
from websocket.io.
Related Issues (20)
- Deprecate #open, use #readyState HOT 1
- server.clients grows over time HOT 2
- Method writeUInt16BE missing in Node 0.4 HOT 1
- Leverage ws parsers HOT 6
- Replace logger by debug?
- Server reference in Socket
- Error handling must be reworked HOT 8
- separate servers for sub-protocols (i.e. Sec-WebSocket-Protocol) HOT 1
- client tracking bug in handleUpgrade HOT 14
- How to filter clients with the origin? HOT 8
- Sub-protocol support broken
- Mask Send Messages
- WSS enable ? HOT 2
- IP Adress HOT 2
- Empty/Undefined error-Events
- Warning in Node 6.1.0 HOT 1
- (node:6620) DeprecationWarning: process.EventEmitter is deprecated. use require('events') instead. HOT 5
- Parser.prototype.__proto__ = EventEmitter.prototype; TypeError: Cannot read property 'prototype' of undefined HOT 4
- Uses vulnerable version of ws
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 websocket.io.