zettajs/zetta

Multiplexed WebSocket - Application level ping/pong support

Closed this issue · 2 comments

"When using a fully-featured websocket client, sending a ping every now and again to keep the socket open is built-in. However, when working with plain javascript in the browser, that option is not available.

Would be it possible to allow a message along the lines of:

{type: 'keep-alive'}

or

{type: 'ping'}

And a corresponding ack response?"

Also, check the status code error that is returned when type is not valid.

(Regarding the "check status code error")

The documentation for error codes says the status is 400 for bad JSON and 405 for an unknown type value.

When I send an unknown type (e.g. "ping"), I do not get the expected 405. The status returned is instead 400.

{"type":"ping"}
{"type":"error","code":400,"timestamp":1452714090158,"message":"Message validation failed."}

Implemented in master, will be included in 1.0.0-beta.6