2016-06-09 176 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