用websocket测试工具能连,用AsyncTcpConnection提示Sec-WebSocket-Accept not found

later

用在线测试工具能连接,用workerman连接提示如下:

Sec-WebSocket-Accept not found. Header:
HTTP/1.1 404 Not Found
Date: Sat, 17 Nov 2018 00:37:42 GMT
Content-Type: text/html;charset=iso-8859-1
Content-Length: 232
Connection: keep-alive
Cache-Control: must-revalidate,no-cache,no-store
binace connection closed
not foundokex connection closed

代码如下:// ssl需要访问443端口

$con = new AsyncTcpConnection('ws://*.*.com:10440/ws/v1');
// 设置以ssl加密方式访问,使之成为wss
$con->transport = 'ssl';
$con->onConnect = function ($con) {
    echo "connect ...\r\n";

};
$con->onMessage = function ($con, $data) {

};
$con->onClose = function($con){
    echo "connection closed\n";

};
$con->connect(); 

浏览器里能连接,回复如下:

Connection:
upgrade

Date:
Sat, 17 Nov 2018 01:13:16 GMT

sec-websocket-accept:
XQNrDkn+vJ8+BpLIidRiEHyfGFo=

Server:
nginx

upgrade:
websocket
4939 4 0
4个回答

later

浏览器里能回复,回复的内容如下:

Connection:
upgrade

Date:
Sat, 17 Nov 2018 01:13:16 GMT

sec-websocket-accept:
XQNrDkn+vJ8+BpLIidRiEHyfGFo=

Server:
nginx

upgrade:
websocket

  • 暂无评论
walkor 打赏

发下ws地址

  • later 2018-11-17

    wss://real.okex.com:10440/ws/v1 需科学上网

walkor 打赏

[attach]1401[/attach]

[attach]1402[/attach]
这里测试没有问题,能看到对方返回的http头是正常的

  • later 2018-11-17

    是我的自已的问题,谢谢老大

  • rockman1107 2018-12-08

    @1 我也遇到了这个问题,在浏览器端可连接,ws地址是:wss://ws.coincap.io/prices?assets=bitcoin,ethereum,代码跟你截图代码基本就差个地址了,另外那个openssl版本这边需要用sslv3才不会报错,所以transport值设置成了sslv3

中榜

我也报这个错了,大神帮我看看

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