Comments (8)
Hi,
Yes, this behavior has changed as it was incorrect before. However, documentation is inconsistent and I haven't noticed that. If you look a bit above that state transitions, the disconnected
state was described as:
The Pusher connection was previously connected and has now intentionally been closed.
In your case, losing connectivity is not an intentional disconnect and the connection should not enter the disconnected
state. I'd rather check if the state is connected
.
Sorry about that, I'll update the documentation.
from pusher-js.
Okay clear.
And what about the delay before the state-change callback gets called?
from pusher-js.
It has also changed, as described in the changelog. We basically dropped support for browser online detection, as it was unreliable and was giving false negatives. There's only one algorithm that uses online detection - if a client is not connected and the browser emits an online event, pusher-js will try reconnecting immediately, to speed up the reconnection process.
Currently, only ping/pong messages are used to check if the connection is working. The default timeout before ping is sent is 120s and there's another 30s waiting for the response, before disconnecting.
from pusher-js.
Okay, I must have missed it in the changelog.
Currently, only ping/pong messages are used to check if the connection is working. The default timeout before ping is sent is 120s and there's another 30s waiting for the response, before disconnecting.
Okay. False negatives are bad but this means that it now always takes somewhere between 0 and 150 sec before a disconnection is known to the client right? On the other hand: does this also solve the problem of false positives (Other members in a presence channel not leaving the channel when the browser is closed), or is that something Pusher (not the js. lib) should solve?
Thanks for your quick reply.
from pusher-js.
Sorry I lost track of this thread. Yes, it will take between 0 and 150s to detect disconnection. If you really depend on connection state, you can alternatively lower the activity timeout slightly (I would advice around 30s, not less) and it will decrease the delay (to 30s in this example).
Generally, closing the browser window should close the TCP connection and it should be detected on the server side. Otherwise, servers should remove disconnected clients from presence channel automatically. The algorithm for detection is pretty much the same - ping after X seconds of inactivity, wait Y second for response and close the connection if no messages are received.
from pusher-js.
From 2.1.6 when a browser emits the offline event, the client will send a ping message immediately and if doesn't get a response after pong timeout (30s by default) it will try reconnecting, so you don't need to wait 120s for the ping. Can we close this issue?
from pusher-js.
Closing, because the default disconnection detection lag has been reduced significantly (150s -> 30s) and there's no more activity in this issue.
from pusher-js.
Cool!
from pusher-js.
Related Issues (20)
- Pusher issue when packaged with custom NPM module HOT 1
- Please don't deprecate React Native in `pusher-js`
- Pointer not working to decline cookies HOT 2
- WebSocket Compression HOT 11
- Pusher User Authentication Endpoint and params not being overridden HOT 3
- Gateway 504 error and how to handle it gracefully HOT 2
- { "type": "PusherError", "data": { "code": null, "message": "Missing parameter: data.user" } } HOT 3
- BUG - Error: Connection closed. (active status - Code With Antonio) HOT 16
- YukTam HOT 1
- Bug: Webhook not triggered after subscribe and unsubscribe event HOT 1
- 401 (Unauthorized) when subscribing to private-channel (Vue/Laravel)
- Incorrect TypeScript types for class with `moduleResolution: "nodeNext"` HOT 2
- Error `Unable to resolve module @react-native-community/netinfo` HOT 1
- TypeError: Object(...) is not a function at Object.randomInt HOT 10
- PWA HOT 1
- Constant connection state changes when using other than ws transports HOT 3
- Not actuall stats HOT 6
- Pusher-JS doesnt play well with NextJS 14 : Uncaught SyntaxError: Unexpected token ':' HOT 2
- Providing Custom Handler, Internal Endpoint Still Calls
- Pusher client is not binding correctly on presence channels but on public ones yes HOT 2
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 pusher-js.