apache 按照官网的参考配置小程序连接不成功 wss

wczcf

apache配置:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so

httpd-ssl配置:

<VirtualHost *:443>

    DocumentRoot "C:\WWW\grpt\public"
    ServerName xxx.xxx.com:443
    SSLEngine on
    ProxyRequests Off
    ProxyPass /wss ws://0.0.0.0:8008
    ProxyPassReverse /wss ws://0.0.0.0:8008
    SSLProtocol all -SSLv2 -SSLv3
    SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
    SSLHonorCipherOrder on

    SSLCertificateFile C:/phpStudy1/Apache/conf/grpt_cert/public.pem
    SSLCertificateKeyFile C:/phpStudy1/Apache/conf/grpt_cert/214493524050581.key
    SSLCertificateChainFile C:/phpStudy1/Apache/conf/grpt_cert/chain.pem

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
        SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory "C:/phpStudy/Apache/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    CustomLog "C:/phpStudy/Apache/logs/ssl_request.log" \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

workerman启动运行:

----------------------- WORKERMAN -----------------------------
Workerman version:3.3.90          PHP version:5.6.27
------------------------ WORKERS -------------------------------
worker                 listen                    processes status
ChatGateway            websocket://0.0.0.0:8008   1        
YourAppBusinessWorker  none                       4        
Register               text://0.0.0.0:8004        1        
----------------------------------------------------------------

小程序代码(运行结果):

     wx.connectSocket({
        url: 'wss://' + domain+’/wss‘, 
        data: parame.data,
        header: {
          'content-type': 'application/json'
        }, 
        protocols: parame.protocol,
        method: "GET",
        success: res => { 
          if (parame.success){
            parame.success(res);
          }
        }
      })

// 'wss://' + domain 这样报错 failed: Error during WebSocket handshake: Unexpected response code: 302
// 'wss://' + domain+’/wss‘ 这样报错 failed: Error during WebSocket handshake: Unexpected response code: 503

阅读 4141
3个回答

sm2010

连接的域名和apache里的ServerName不匹配吧

maq

ssl 的握手到底是在哪个环节完成的呢?

反正我用 Nginx 作反向代理,用 proxy_pass 转发给 Workerman 的时候,是由 Workerman 这边来负责 ssl 握手的。

看你这个 Apache 的配置,貌似 Workerman 这边并没有负责 ssl 握手,也许问题在这里吧……

  • wczcf 2018-04-19

    我可能要转Nginx了

we2018

ServerName没有端口号的

  • 暂无评论