0

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.

quadroid
  • 8,444
  • 6
  • 49
  • 82
  • type `localStorage.debug = '*';` into your chrome console, then refresh the page for further socket.io-debug informations – InsOp Jun 09 '16 at 09:27

2 Answers2

1

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.

Community
  • 1
  • 1
quadroid
  • 8,444
  • 6
  • 49
  • 82
0

Please pay attention on the following points, and modify in your application and try again.

  1. Try to run node-red application on local firstly via https://github.com/node-red/node-red#developers. Especially run command grunt build to complete your application.
  2. Try to remove the ignore folders

    coverage
    credentials.json
    flows*.json
    nodes/node-red-nodes/
    node_modules
    public
    locales/zz-ZZ
    nodes/core/locales/zz-ZZ
    

    in the .gitignore, then deploy the whore completed project on Azure.

  3. Modify the uiPort: process.env.PORT || 1880, in settings.js file.

Any further concern, please feel free to let me know.

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • Thanks for your effort, I did build and run everything locally, and it worked fine. I did as well build the solution on the azure webapp using the console. The problem originated from our corporate infrastructure, more precisely the proxy. I will add an Answer.. – quadroid Jun 10 '16 at 07:02