异步websocket客户端遗漏消息的问题

使用的swoole 1.9.19,1.9.18也测试了,同样的问题

在websocket server onHandShake给客户端发送了验证消息,客户端遗漏了,异步的websocket client偶尔才能收到auth信息,使用浏览器的html5 的websocket客户端没有该问题,所以想问一下怎么回事?

异步websocket客户端程序

use Swoole\Http\Client;

$cli=new Client('127.0.0.1',3000);
$cli->set(['timeout' => 3.0,'keep_alive' => true]);
$cli->setCookies(['access_token'=>"access_token"]);
$cli->on('message', function ($cli, $frame) {
    switch($frame->opcode){
       case 0x1:
          echo $frame->data."\n";
          break;
      case 0x2:
          echo "bin\n";
          break;
      case 0x9:
          echo $frame->data."\n";
          break;
      default:
          echo $frame->data."\n";
    }
});
$cli->upgrade('/?name=xiaoming&email=xiaoming@163.com', function ($cli) {
    if($cli->statusCode>200){
       echo "auth faild\n";
       $cli->close();
       return false;
    }
    $cli->push("server 在吗?");
});

从websocket server的debug信息看,每次都能看到发送了

{"type":"auth","data":{"name":"xiaoming","email":"xiaoming@163.com","message":"welcome"}}

2017-09-08 15:28
0

要回复问题请先登录注册