Comments (8)
Hello, this could mean that client side timeout was called. You could face ephemeral port problem - https://centrifugal.dev/docs/server/infra_tuning#ephemeral-port-exhaustion . But I can't say for sure.
If you don't observe the same behaviour in local environment – then it's sth infrastructural and most probably network stack related. If you can reproduce this with local Centrifugo – we can take a closer look.
Is the issue related to Centrifugo's configuration or is it just how the Centrifugo JS library works?
In normal situation such errors may happen but should be relatively rare.
from centrifugo.
I should note that the errors are observed while running some kind of synthetic test. It emulates 100 concurrent websocket connections from the client and subscribes to the "presence" channel.
All connections are established eventually, but at some point the aforementioned errors observed. If some delay is added between subscriptions (let's say 300ms) - there is no sign of error in the console.
From the server's side, I can't stress enough how low the load right now. With only one replica of Centrifugo it uses ~ 300 TCP connections when triggering the test. Apart from that, even if I scale to 20 replicas - the picture is the same, but according to the recommendations in the doc scaling should help in cases with port exhaustion.
centrifugo # netstat -tanp | wc -l
309
from centrifugo.
If it's a synthetic test you may hit limitations on client side. Are you opening many connections from a single browser? I suppose the best you can do if you want help with this is to provide reproducer, there are too many things which may be involved.
from centrifugo.
Yes, indeed. I can confirm that the test has been performed from a single browser. Having the TCP dump I observe that some of TCP connections are reset on the client's side.
I may have a better understanding of the situation now. In case the server's websocket connections reset, due to events such as Nginx reload config or rolling restart for Centrifugo containers, the client will attempt to establish new connections. However, it may encounter a limit on the number of concurrent connections allowed by the browser.
I can imagine that on the server's side, the action item is to try to minimize the situations when the connection is reset. What about the client-side? Are there any recommendations on how to handle it correctly?
from centrifugo.
I don't know the real-life valid use case when so many connections should be properly established from one device.
If you need to load test Centrifugo - better using specialized tools outside of browser.
If you have real app when there are so many connections and need to reconnect properly - think about different delays for reconnection (SDKs support such option), as you mentioned it helped you already. But again - sounds rather unusual, I don't understand what you want to achieve/test. Probably consider moving WebSocket connection to Service worker or Shared worker and re-use connection from different tabs.
from centrifugo.
We were trying to reproduce an incident-related case, but as you highlighted we were doing it wrong.
I found a k6 benchmarking test in the project. Would you recommend using it to test the number of clients/ws connections the installation can handle?
from centrifugo.
I found a k6 benchmarking test in the project. Would you recommend using it to test the number of clients/ws connections the installation can handle?
You can, probably adapt it a bit for your needs. Note that you can still hit limitations of client when running benchmark using k6 - like local open file limits, local resource usage. BTW, ChatGPT writes k6 scripts pretty well - was using it to write this script when was testing sth.
from centrifugo.
Closing, the main question was addressed.
from centrifugo.
Related Issues (20)
- [feature] Silently Reject Publish Attempts on Proxied Channel Without Sending Client Errors HOT 4
- [question] What are the ways of decreasing the message payload? HOT 1
- [feature] Better error message when subscription token is used as connection token
- Unable To Connect With anonymous mode HOT 4
- [feature] serve admin interface via http2 HOT 4
- [feature] Send server time in initial connect response. HOT 2
- [question] Upgrading to 4.1.5 increase in response time HOT 3
- [feature] Support for MessagePack Serialization HOT 2
- How to add multyple aud for a token in config file HOT 1
- [question] History StreamPosition and circular offsets. HOT 7
- [question] Centrifugo customization HOT 13
- [question] Support for Rate Limiting Messages Sent to Clients HOT 2
- [bug] centrifugo-pro not getting OnPublishEvents when using a token with channels claim HOT 4
- [bug] Can't pull history with channel JWT HOT 7
- [bug] With protobuf binary, RPCRequest.Data is empty. HOT 3
- [question] jwt invalid token in subscriptions HOT 3
- `bad request` and `disconnect` immediately after connection established HOT 6
- [question] When using gzip compression, http_stream transport fails to connect because of timeout. HOT 4
- [question] Get list of channels that have history 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 centrifugo.