2016-06-09 177 views
0

我遇到了Azure WebApp上的websockets问题。websockets连接超时

我从github克隆了Node-red,并将它发布到Azure中全新的WebApp中(使用VisualStudioOnline)。比我安装所有软件包并使用grunt构建解决方案。 (如所述here

之后,我更改了settings.js并将azure配置为支持websockets。 (如所述here)。

但仍的WebSockets不起作用: Chrome并显示以下错误:

Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

我看不到在服务器端,指示问题的任何日志/警告。

+0

输入'localStorage.debug ='*';'进入你的chrome控制台,然后刷新页面以获得更多的socket.io-调试信息 – InsOp

回答

1

问题来自我们的代理。 Here是一篇描述该问题的文章。

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.

所以我所做的仅仅是强制重定向到HTTPS站点使用下面的重写规则(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> 

而不是一切正常。

0

请注意以下几点,并在您的应用程序中修改并重试。

  1. 尝试首先通过https://github.com/node-red/node-red#developers在本地运行节点红色应用程序。特别是运行命令grunt build来完成您的应用程序。
  2. 尝试删除该文件夹忽略

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

    .gitignore,然后部署到Azure上的妓女完成的项目。

  3. 修改uiPort: process.env.PORT || 1880,settings.js文件。

任何进一步的问题,请随时让我知道。

+0

感谢你的努力,我确实在本地构建和运行了所有东西,并且运行良好。我也使用控制台在azure webapp上构建了解决方案。问题来源于我们的企业基础架构,更确切地说是代理。我会添加一个答案.. – Console