Skip to content

Conversation

@rkistner
Copy link
Contributor

#24 introduced concurrency limits for websockets, similar to what we had with http streams. However, the connection count does not always decrease when a connection is closed, leading to all clients eventually getting an error " [429] Maximum active concurrent connections limit has been reached".

This simplifies it a bit by just tracking the number of websocket clients on the websocket server, instead of attempting to track the individual streams. We could additionally limit the number of streams per client in the future.

@rkistner rkistner requested a review from stevensJourney July 10, 2024 19:39
@changeset-bot
Copy link

changeset-bot bot commented Jul 10, 2024

🦋 Changeset detected

Latest commit: 909f71a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@powersync/service-rsocket-router Patch
@powersync/lib-services-framework Patch
powersync-open-service Patch
@powersync/service-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

code: '429',
// wss.clients.size includes this connection, so we check for greater than
// TODO: Share connection limit between this and http stream connections
if (max_concurrent_connections && wss.clients.size > max_concurrent_connections) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs for wss.clients: https://github.com/powersync-ja/powersync-service/pull/36/files

The size of the set did seem to accurately reflect the number of concurrent connections in the testing I did.

@rkistner rkistner merged commit 0e1c23b into main Jul 10, 2024
@rkistner rkistner deleted the fix-concurrency-limit branch July 10, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants