nats-io/nats-server

Websocket: Server incorrectly sends close message status 1005 or 1006

kozlovic opened this issue · 0 comments

Observed behavior

(This issue was reported internally by @aricart)

When a client does not send any status/payload in the close message, the server detects correctly that situation but is sending back status 1005 (no status specified), which is wrong. It should simply not send any status/payload in its close message frame.
Also, server may send status 1006 (abnormal closure), which according to the specification, this status (like 1005) must not be set as a status code in a close control frame.

Expected behavior

If a client sends a close message frame without status/payload, the server should echo the close message frame without status/payload, and the server should never send status 1006 (even if the server detects a client going away).

Server and client version

Latest

Host environment

N/A

Steps to reproduce

Have a client sends a close message frame without status and observe that server is sending 1005. Also, in some situations, server would send 1006 (when it would detect a write or read error or when considering the connection stale).