Skip to content

WebSocket-over-HTTP doesn't respond to standalone PING when structured according to the standard example #36

@harmony7

Description

@harmony7

When WebSocket-over-HTTP is used according to the standard example, it doesn't handle standalone PING.

This is because of the loop it uses:

        while (wsContext.canRecv()) {
            const message = wsContext.recv();

            if (message == null) {
                // If return value is undefined then connection is closed
                wsContext.close();
                break;
            }

            // Handle the message...
        }

Within wsContext.recv(), js-grip automatically handles PING by writing an outgoing PONG.
However, the ws.Context.canRecv() function only returns true in response to the messages: ['TEXT', 'BINARY', 'CLOSE', 'DISCONNECT'].

Therefore, if the only message in the queue is 'PING', it is never reaches recv().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions