Rate limiter socket #15
-
Hey i'm using hono rate limiter with redis and it work perfectly for me except for socket. this.server.hono.get(
'/ws',
upgradeWebSocket(() => {
return {
onMessage: async (event, ws) => {
const response = await this.triggerEvent(event.data);
if (response || response === false) {
ws.send(JSON.stringify(response));
}
},
}
})
) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 21 replies
-
Can you share a reproduction of this? Which runtime are you using? So, I believe what is happening here is that We can add a helper function, which will run inside the What do you think? We will need to figure out the API but the implementation seems easy |
Beta Was this translation helpful? Give feedback.
-
This looks good. I also want to limit the number of concurrent connections to the socket by a user. So for example user |
Beta Was this translation helpful? Give feedback.
Thank you! I will try to merge this soon (have to finish those tests). Do let me know if you have any more ideas.