Skip to content

feat: ws connection support https redirects before upgrade - #66

Open
hsxfjames wants to merge 1 commit into
X-Profiler:masterfrom
hsxfjames:feat/support-ws-redirects
Open

feat: ws connection support https redirects before upgrade#66
hsxfjames wants to merge 1 commit into
X-Profiler:masterfrom
hsxfjames:feat/support-ws-redirects

Conversation

@hsxfjames

Copy link
Copy Markdown

Background

When the EZM WebSocket service is deployed behind a gateway that enforces HTTP-to-HTTPS redirects, a client configured with ws://example.com/ws should follow this connection flow:

  1. The client sends a WebSocket upgrade request over plain HTTP.
  2. The gateway responds with an HTTP 301 or 302 redirect to the HTTPS endpoint.
  3. The client establishes a TLS connection and sends a new WebSocket upgrade request.
  4. The EZM WebSocket service responds with 101 Switching Protocols, establishing a secure WebSocket connection.

By default, the Node.js ws client does not follow HTTP redirects. As a result, the connection fails when the gateway returns the initial redirect response.

Changes

This PR enables redirect handling by setting followRedirects to true and limits the redirect chain to a maximum of 3 redirects.

This allows WebSocket connections to work in deployment environments where HTTPS is enforced by an upstream gateway, while preventing unbounded redirect chains.

Signed-off-by: Eugene Zheng <hsxfjames@gmail.com>
@hsxfjames
hsxfjames force-pushed the feat/support-ws-redirects branch from 25ad765 to a755505 Compare August 10, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant