Last active
May 24, 2025 00:27
-
-
Save apuravchauhan/c5c7637c40637e871c1d69985283248e to your computer and use it in GitHub Desktop.
ws client to test backpressure with uwebsockets.js [article https://apuravchauhan.medium.com/understanding-backpressure-in-real-time-streaming-with-websockets-20f504c2d248]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebSocket = require('ws'); | |
const port = 9001; | |
const ws = new WebSocket('ws://localhost:' + port); | |
ws.on('message', (data) => { | |
/**Uncomment below To slow the event loop to simulate a slow client */ | |
/* | |
while (new Date().getTime() - start <= 500 ) { | |
// Do nothing - just block the thread | |
} | |
*/ | |
console.log(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original article connected to the gist:
https://apuravchauhan.medium.com/understanding-backpressure-in-real-time-streaming-with-websockets-20f504c2d248