Skip to content

Custom ReasonCode not passed in closeEvent #420

Description

@hazaart

The spec for websocket provides a range for custom reason codes to be sent when closing the websocket (4000-4999). When closing a websocket connection from the client passing a custom reason code, the code is not received within the onclose event.

Code on websocketServer:

    this._httpServer = createServer();
    this._httpServer.listen(port, () => { });
    this._websocketServer = new websocketServer({ httpServer: this._httpServer });

    console.log(`Websocket server now listenening on port ${port}`);

    this._websocketServer.on('request',
        (request) => {
            const connection = request.accept(undefined, request.origin);

            connection.on('message', function (message) {
                //DoSomething
            });
        }
    );

Code on client side: See JSFiddle https://jsfiddle.net/254megph/2/

websocket.close(4000, "manual close");

When closing the connection by clicking the button the JSFiddle, the onClose event is fired with reason code 1000 instead of 4000.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions