Repository navigation
ws-tap: watch live Socket.IO traffic in a second terminal (middleware + viewer, secrets redacted) #5572
Unanswered
Sahil-u07
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi all 👋 sharing a small dev tool in case it's useful to others here.
Whenever an event went missing in one of my Socket.IO apps, I ended up adding
console.logto every handler, restarting, scrolling, and deleting it all again. ws-tap is a middleware that shows every event going in and out of your server, live, in a second terminal.Setup
Then, in another terminal:
How it works
It's a plain
io.usemiddleware. It hookssocket.onAnyandsocket.onAnyOutgoingon each socket, so it sees everything a socket receives and sends, includingio.emitand room broadcasts, plus disconnects with the reason. Events go either to the console or, withviewer: true, as newline-delimited JSON over a localhost TCP socket to the viewer.What you get
ppauses (events are held and printed on resume),ffilters by event name or@socket-idpassword/token/secret/authorizationkeys are redacted at any depth, inside your app, before anything reaches the viewerNODE_ENV=productionunless you passenabled: trueCompatibility
Tested against socket.io 4.8.x (needs 4.5+ for
onAnyOutgoing). Node 22.13+. Other namespaces:io.of('/admin').use(tap(...)).Repo: https://github.com/Sahil-u07/ws-tap
npm: https://www.npmjs.com/package/@sahil-u07/ws-tap
Feedback I'd love
All reactions