Search code examples
node.jsazurewebsocketnode-rediisnode

websockets connection does time out


I got Problems with websockets on my Azure WebApp.

I cloned Node-red from github and published it onto a brand new WebApp in Azure (using VisualStudioOnline). Than I installed all packages and build the solution using grunt. (As described here)

After that I changed the settings.js and configured azure to support websockets. (as described here).

But the websockets still do not work: Chrome does show the following Error:

Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

I can not see any Logs/Warnings on the server side that indicate problems.


Solution

  • The problem originated from our proxy. Here is a Post that describes the Problem.

    If an unencrypted WebSocket connection (ws://) is used, then in the case of transparent proxy servers, the browser is unaware of the proxy server, so no HTTP CONNECT is sent. As a result, the connection is almost likely to fail in practice today.

    If an encrypted WebSocket Secure connection (wss://) is used, then in the case of transparent proxy servers, the browser is unaware of the proxy server, so no HTTP CONNECT is sent. However, since the wire traffic is encrypted, intermediate transparent proxy servers may simply allow the encrypted traffic through, so there is a much better chance that the WebSocket connection will succeed if an encrypted WebSocket connection is used.

    Therefore I did just force a redirect to the HTTPS site using the following rewrite rule (web.config)

    <rule name="https redirect" stopProcessing="true">
       <match url="(.*)" />
       <conditions>
           <add input="{HTTPS}" pattern="off" ignoreCase="true" />
       </conditions>
       <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
    </rule>
                 
    

    And than everything works as expected.