websockets connection does time out

≯℡__Kan透↙ 提交于 2019-12-12 05:38:28

问题


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.


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/37721187/websockets-connection-does-time-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!