Vic
Vic

Reputation: 723

WebSocket client can't connect to cloud server through corporate proxy except for web browsers! (ETIMEDOUT)

I'm trying to connect a WebSocket client (corporate Node.JS server) to a Cloud server, but it times out (connect ETIMEDOUT error).

I'm not sure which needs configuration... Linux, Node.JS or the WebSocket Client?

I've already configured the proxy for Linux (export proxy/https_proxy), and for Node.JS (npm config set proxy/https_proxy) but the problem persists!

I'm using the ws library found in https://npmjs.com and implemented it without any sort of options except setting port.

Any advice?

EDIT: Works fine in the web browser, by the way.

Upvotes: 0

Views: 1351

Answers (1)

josh3736
josh3736

Reputation: 145162

node does not automatically use any form of configuration for making HTTP requests through proxies -- ie, node does not read the PROXY or HTTPS_PROXY environment variables. npm config set proxy only affects npm itself.

In other words, node programs always try to access servers directly. It appears your network requires HTTP requests to go through a proxy, and direct connections are being silently dropped.

If you want your program to make HTTP requests through proxies, you must do so manually. The http-proxy-agent module can help you do this.

Upvotes: 2

Related Questions