通过Apache ProxyPass发出任何请求后如何修复Node.js崩溃

时间:2019-05-31 12:50:13

标签: node.js apache websocket

每当我发出任何请求... Web-Socket或常规获取请求时,在请求结束时(Web-Socket关闭或获取完成),节点js服务器都会崩溃

{ Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }

这仅在Windows上发生,但在Centos VPS上可以正常工作

使用的技术:

Windows 10 with xampp v3.2.2 and Apache/2.4.29 (Win32)
Node v10.15.0
Express 4.16.3
ws 3.3.3 from npm

我尝试查看express和ws,以查看是否有可能错过的错误处理程序,但我无法弄清是否是这种情况。

我也尝试像在某人配置中看到的那样,在ProxyPass行后面添加retry=0 timeout=60 keepalive=On,但这也没有任何改变。

这是我当前在Windows上的Apache虚拟主机配置

<VirtualHost *:80>
    DocumentRoot C:\Users\username\Desktop\Developement\app\public_html
    ServerName app.localhost
    ErrorLog "C:\Users\username\Desktop\Developement\logs\error.log"
    CustomLog "C:\Users\username\Desktop\Developement\logs\access.log" common

    <Directory "C:\Users\username\Desktop\Developement\app\public_html">
         DirectoryIndex index.php
         AllowOverride All
         Order allow,deny
         Allow from all
         php_value auto_prepend_file C:\Users\username\Desktop\Developement\app\prepend.php
    </Directory>

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyRequests Off
    RewriteEngine On

    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule .* ws://localhost:8080%{REQUEST_URI} [P]

    ProxyPass /ws http://127.0.0.1:8080 retry=0 timeout=60 keepalive=On
    ProxyPassReverse /ws http://127.0.0.1:8080

    ProxyPass /login http://127.0.0.1:8080/login retry=0 timeout=60 keepalive=On
    ProxyPassReverse /login http://127.0.0.1:8080/login

</VirtualHost>
<VirtualHost *:443>
    DocumentRoot C:\Users\username\Desktop\Developement\app\public_html
    ServerName app.localhost
    ErrorLog "C:\Users\username\Desktop\Developement\logs\error.log"
    CustomLog "C:\Users\username\Desktop\Developement\logs\access.log" common

    <Directory "C:\Users\username\Desktop\Developement\app\public_html">
         DirectoryIndex index.php
         AllowOverride All
         Order allow,deny
         Allow from all
         php_value auto_prepend_file C:\Users\username\Desktop\Developement\app\prepend.php
    </Directory>


    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    SSLProxyEngine On
    SSLEngine on
    SSLCertificateFile "C:\xampp\apache\cert\app.localhost\server.crt"
    SSLCertificateKeyFile "C:\xampp\apache\cert\app.localhost\server.key"
    ProxyRequests Off

    RewriteEngine On

    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule .* ws://localhost:8080%{REQUEST_URI} [P]

    ProxyPass /ws http://127.0.0.1:8080 retry=0 timeout=60 keepalive=On
    ProxyPassReverse /ws http://127.0.0.1:8080

    ProxyPass /login http://127.0.0.1:8080/login retry=0 timeout=60 keepalive=On
    ProxyPassReverse /login http://127.0.0.1:8080/login

 </VirtualHost>

我基本上是从centos服务器复制了此配置,因此2之间只有细微的差别,即目录和<Directory>标签

0 个答案:

没有答案