Skip to content

Instantly share code, notes, and snippets.

View btucker's full-sized avatar
👋

Ben Tucker btucker

👋
View GitHub Profile

I need a way to write WebSocket client code that runs on a server in Node.js.

What it must do: Exactly what this browser-based app does, only running on a server, without the UI stuff.

https://github.com/scripting/1999client/blob/master/code.js#L133

It would make so much sense if Node implemented exactly the browser API for WebSockets, native. So much of Node works that way. But this is one of those times when it doesn't.

There are a few toolkits that do WebSockets on the server. But there isn't simple clean sample code that I've been able to convert to this application. I tried! :-)