小程序使用gateway握手失败,返回502

JasonKit

小程序使用wss协议访问gatewayworker,出现以下报错

WebSocket connection to 'wss://bafanghui.xinnar.net/wss' failed: Error during WebSocket handshake: Unexpected response code: 502

监听返回的报错信息如下:错误内容我没看懂.

PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request in /data/release/bafanghui_chatroom/vendor/workerman/workerman/Connection/TcpConnection.php on line 567

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request in /data/release/bafanghui_chatroom/vendor/workerman/workerman/Connection/TcpConnection.php on line 567

SSL Handshake fail.
Buffer:54502f312e310d0a557067726164653a20776562736f636b65740d0a436f6e6e656374696f6e3a20757067726164650d0a486f73743a206266685f776562736f636b65740d0a507261676d613a206e6f2d63616368650d0a43616368652d436f6e74726f6c3a206e6f2d63616368650d0a4f726967696e3a20687474703a2f2f626166616e676875692e6465760d0a5365632d576562536f636b65742d56657273696f6e3a2031330d0a557365722d4167656e743a204d6f7a696c6c612f352e30202857696e646f7773204e542031302e303b20574f57363429204170706c655765624b69742f3533372e333620284b48544d4c2c206c696b65204765636b6f29204368726f6d652f36302e302e333131322e37205361666172692f3533372e33360d0a4163636570742d456e636f64696e673a20677a69702c206465666c6174652c2062720d0a4163636570742d4c616e67756167653a207a682d434e2c7a683b713d302e380d0a5365632d576562536f636b65742d4b65793a2072466f6f4156333871347a463850436f4d55387962773d3d0d0a5365632d576562536f636b65742d457874656e73696f6e733a207065726d6573736167652d6465666c6174653b20636c69656e745f6d61785f77696e646f775f626974730d0a0d0a

[attach]911[/attach]

我是配置了443端口转发到6501端口访问的,会是这个配置的问题吗?

[attach]912[/attach]

10614 4 0
4个回答

walkor

nginx代理了ssl,gateway就不用开ssl了,开了两层ssl会出问题。

  • JasonKit 2018-01-18

    真的是这样,成功了,谢谢大佬!

jjfly

您好 问题解决了吗?我nginx代理了ssl,gateway没有代理也不行 求指导

  • JasonKit 2018-01-18

    我把gateway的取消了,然后就可以了,你是不是nginx代理设置的不对?

  • JasonKit 2018-01-18

    你报的错误和我的一样吗?

楊zzzzzz

我的一直是502 您方便把您的nginx配置贴一下吗

  • JasonKit 2018-01-19

    upstream bfh_websocket {

    ip_hash; #分布式部署时可启用

    server 127.0.0.1:6501;#换成具体的服务器对应的IP与端口
    #server 10.1.2.11:8282#换成具体的服务器对应的IP与端口 如果只有一台可以去掉这一行方便以后扩展

    }
    server {
    listen 443;

    root /data/release/bafanghui/public;
    server_name #你的域名;
    charset utf-8;
    
    ssl on;
    ssl_certificate  #crt文件路径;
    ssl_certificate_key  #key证书文件路径;
    
    ssl_session_timeout 5m;
    ssl_session_cache shared:SSL:50m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2  SSLv2 SSLv3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    
    index index.php index.html index.htm;
    
        location /wss {
                proxy_pass http://bfh_websocket;  #前面的upstream websocket对应
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        proxy_read_timeout 60s;#默认为60s
        proxy_send_timeout 60s;#默认为60s
        break;
    }
    
    location / {
                if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=/$1  last;
                break;
        }
    }
    
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    }

  • 楊zzzzzz 2018-01-19

    谢谢 原来是我小程序里写错了 ⊙﹏⊙‖∣ 配置差不多

  • 茫茫星空 2019-04-07

    我的配置和你的差不多,但为什么链接的时候报502

赵磊

在哪儿配置?第一次写小程序

  • 暂无评论
年代过于久远,无法发表回答
🔝