Skip to content

Cannot connect to a websocket endpoint using HPM, the socket is immediately closed #495

Open
@slvrtrn

Description

@slvrtrn

Is this a question?

No

Is this a bug report?

Yes

Is this a feature request?

No

Steps to reproduce

Steps to reproduce are similar to https://stackoverflow.com/questions/59579433/proxied-websocket-connection-is-immediately-closed
However, in my case, we do not use webpack so the accepted answer is not suitable for us.

Expected behavior

A socket to the endpoint is opened and accepting messages, similar to if I connect to the endpoint without HPM.

Actual behavior

If I use a tool like https://websocketking.com/, I receive

Could not connect to "ws://localhost:3003/api/ws". You may be able to find more information using Inspector/Dev Tools on this page.

networks says: Error during WebSocket handshake: Unexpected response code: 400
HPM console says (when using the similar code as specified in the stack overflow question):

13:37:48.231Z DEBUG: socket is destroyed true
[HPM] Upgrading to WebSocket

If I use the same tool but try to connect to the server WS endpoint directly (i.e. by using just a different port), everything works fine.

Setup

Ubuntu 20.04

client info

Node 14, HPM 1.0.6

target server info

A typical WS server that works fine without HPM

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions