Workarounds for the lack of websockets throttling in browsers

Browsers like Firefox or Chrome support network handling. This is very helpful during development, as the load times on localhost don’t reflect what’s is going to happen on a real server and this feature helps to simulate some of the real behavior.

However, none of the browsers seem to support throttling websockets. I know for sure that Chrome doesn’t support it, it doesn’t work in Firefox either, but I didn’t look for more details.

In the absence of this feature, do you have any idea how websockets could be throttled throughout the whole app? I think something like adding a random sleep call before sending out a message on a channel or before responding to a message would help.

I know how to add it to particular handlers, but I don’t know how to add it for all the connections in the app.

2 Likes