Skip to content
ConfuSomu edited this page Oct 21, 2017 · 8 revisions

How well does websocketd scale to large numbers of concurrent connections?

I'm not the developer, but AFAIK, you'd be limited by the Server's RAM. Every opened connection would fork a process. So, if you're writing your server in e.g. C, this could be quite small. If you're using something like Perl (as i am), or PHP, this oculd be around 5MB to 10MB.

How much latency does websocketd introduce?

Not the developer, but it should be absolutely minimal, once the connection is established. The initial connection might take some milliseconds, because websocketd will have to fork of a process and start your server process.

How can I send multiple-line messages?

You can use escape codes. Since you'll most likely be sending from Javascript, you can either wrap your output with JSON.stringify("first line\nsecond line") or escape("first line\nsecond line"). In your application code, you'll need to JSON.parse(msg) or unescape(msg) respectively upon receiving a message.

How are my programs killed after a disconnect?

I've tried catching HUP, TERM and INT, and none of them seem to be sent to my program when I disconnect the websocket. But I have to do some clean-up before exiting, so what can I do?

  • The answer was simpler than I thought: websocketd simply closes STDIN, so the while () loop ends, and the program simply exits.

What happens when the browser has network issues, and a 'dirty' disconnect happens

I connected to the websocket, and put my phone in airplane mode. The browser detects this immediately and shows an unclean disconnect, but my server program just lingers on. Implementing some last-time-I-received-data scheme would be trivial, but I am wondering if there's some inactivity timeout built-in?

  • and the instant I submitted this last paragraph, I actually did get a timeout. After 17 minutes.
Clone this wiki locally