workman写websocket客户端问题

zhucecc

有2个问题

1 服务端的链接格式为ws://123.207.167.163:9010/ajaxchattest

demo上的ws客户端,跑不通,send后收不到服务端回复消息。

2 然后比如说ws的服务端,在客户端第一次链接后会发送一条消息,但是workman客户端触发不了onMessage的事件

6215 4 0
4个回答

walkor 打赏

贴代码

  • 暂无评论
zhucecc
<?php

use Workerman\Worker;
use Workerman\Connection\AsyncTcpConnection;
require_once __DIR__.'/../../../Workerman/Autoloader.php';

$worker = new Worker();

$worker->onWorkerStart = function($worker)
{
    $con = new AsyncTcpConnection('ws://121.40.165.18:8088');
//    $con = new AsyncTcpConnection('ws://123.207.167.163:9010/ajaxchattest');

    $con->onConnect = function($con)
    {
//            $params = '';
//            $con->send($params);

    };

    $con->onMessage = function($con, $data)
    {
        echo "recv: $data\n";

    };

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

    $con->onError = function($con, $code, $msg)
    {
        echo "Error code:$code msg:$msg\n";
    };

    $con->connect();
};

Worker::runAll();
  • 暂无评论
walkor 打赏

[attach]696[/attach]
测试正常,没有你说的情况

  • walkor 2017-07-20

    prod-live-entry.playbattlegrounds.com对Sec-WebSocket-Key有严格的检查,请更新下workerman的版本,已经做了修复

  • zhucecc 2017-07-21

    @1:更新到3.4.6,问题解决,真的非常感谢,非常感谢!

zhucecc

在线测试结果

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