Comments (7)
One thing we could do is have polling send a noop
packet when websocket connects to speed up the poll cycle.
from engine.io-client.
It also occurred to me that an elegant way to handle this is to fire events on the current transport when another potential upgrade transport connects.
from engine.io-client.
I am still not able to consistently reproduce this behavior. We were able to fix this by having the server send a ping packet after a successful probe was received.
Obviously, this is not The Right Way to do things, but it helps to close an opening poll transport in a reasonable amount of time. You can find the changes for this in my branch (I didnt request a pull because I hope somebody will provide a better solution for this)
from engine.io-client.
What do you think about sending a noop packet to the open transport after a probe connection is established?
from engine.io-client.
I am not sure if this is the right approach:
To give a context, I am posting a part of the maybeUpgrade function of the engine.io server. Please note the 'PLACEHOLDER' comment
Socket.prototype.maybeUpgrade = function (transport) {
// [...]
var self = this;
function onPacket (packet) {
if ('ping' == packet.type && 'probe' == packet.data) {
transport.send([{ type: 'pong', data: 'probe' }]);
/* PLACEHOLDER */
} else if ('upgrade' == packet.type) {
// [...]
} else {
transport.close();
}
}
transport.on('packet', onPacket);
};
At first, I thought the issue could be solved be directly sending some information on the 'not-probed' transport.
something like self.sendPacket('ping','post-probe')
The problem is, that sometimes the self.transport was not in a state to be able to send something --> Error
Same thing goes for self.transport.send([]);
(well, the Socket calls it in flush, so it was clear it would fail too).
I "resolved" the issue by changing the ping function to accept also a custom pingInterval. Everything in the range from 500ms to 2000ms works consistently. But, as I said before, I doubt that specific time-based intervals are a good approach for this.
Maybe some kind of serialization would help on the client though? Something like "probe only when a poll connection is established", so it is guaranteed there is a poll connection going to the server, that can then be closed? Only thinking aloud here though, but I'd love to see some good ideas we could try to implement.
from engine.io-client.
The key is to queue the packet on the Socket
instead of trying to write it directly to the Transport
(keep in mind that socket does the buffering, not the transport). And we also probably want to add a noop
type to the protocol parser in engine.io-client
.
from engine.io-client.
Fixed in engine.io
from engine.io-client.
Related Issues (20)
- Stop silently closing socket on window beforeunload event HOT 1
- Critical vulnerability with xmlhttprequest-ssl package, needs updating HOT 3
- Dependency update: ws (due to ReDOS) HOT 4
- vulnerability in package HOT 2
- engine.io-client 5.x contrib/xmlhttprequest-ssl/XMLHttpRequest.js contains security vulnerability CVE-2020-28502 HOT 2
- remove support for old platforms HOT 3
- Use native whatwg instead? HOT 2
- High severity vulnerabilities introduced in your package HOT 3
- Sends whole ArrayBuffer instead of fragment HOT 3
- Type inconsistencies with query option HOT 3
- Broken ES5 support for builds (because of globalThis) HOT 1
- The check for websocket transport fails HOT 7
- memory leak on reconnection when `closeOnBeforeunload` is true HOT 1
- WebTransport: Add WebTransport as a new transport HOT 4
- npm test is failing for the latest version:6.4.0
- setImmediate is not defined HOT 1
- [Browser] Doesn't switch to polling when WebSocket is undefined.
- Change URL max length to 8000 or at least add option/config
- Option to use `fetch` instead of `XMLHttpRequest` for polling HOT 2
- Support nodejs client for WebTransport 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 engine.io-client.