Closed 52fhy closed 7 years ago
这里关闭的fd并不相同,怎么证明是重复回调?
@matyhtf 没有调用onOpen
升级一下swoole的版本试试吧。
@matyhtf 虽然没有调用onOpen,但是发现调用了Connect:
$serv = new \swoole_websocket_server('0.0.0.0', '9501');
$serv->set(array(
'worker_num' => 8,
'daemonize' => true,
'max_request' => 1000,
'max_conn' => 65000,
'dispatch_mode' => 2,
'debug_mode'=> 1,
'task_worker_num'=>100,
'log_file' => "webServer.log",
'buffer_output_size' => 32 * 1024 *1024,
'heartbeat_check_interval'=>60,
'heartbeat_idle_time' => 600,
));
$serv->on('Start', array($this, 'onStart'));
$serv->on('WorkerStart', array($this, 'onWorkerStart'));
$serv->on('Open', array($this, 'onOpen'));
$serv->on('Message', array($this, 'onMessage'));
$serv->on('Task',array($this,'onTask'));
$serv->on('Finish',array($this,'onFinish'));
$serv->on('Close', array($this, 'onClose'));
$serv->on('Connect', function ($server, int $fd, int $from_id){
My_Echo("client Connect----->fd: {$fd}" .'---'.$from_id);
});
$serv->start();
目前还不清楚是怎么调用的。
[2017-04-07 17:08:42] INFO: Start
[2017-04-07 17:08:43] INFO: client Connect----->fd: 1---0
[2017-04-07 17:08:43] INFO: client Close----->fd: 1
[2017-04-07 17:08:44] INFO: client Connect----->fd: 2---0
[2017-04-07 17:08:44] INFO: client Close----->fd: 2
[2017-04-07 17:08:44] INFO: client Connect----->fd: 3---0
[2017-04-07 17:08:44] INFO: client Close----->fd: 3
[2017-04-07 17:08:45] INFO: client Connect----->fd: 4---0
[2017-04-07 17:08:45] INFO: client Close----->fd: 4
[2017-04-07 17:08:45] INFO: client Connect----->fd: 5---0
[2017-04-07 17:08:45] INFO: client Close----->fd: 5
[2017-04-07 17:08:46] INFO: client Connect----->fd: 6---0
[2017-04-07 17:08:46] INFO: client Close----->fd: 6
[2017-04-07 17:08:46] INFO: client Connect----->fd: 7---0
[2017-04-07 17:08:46] INFO: client Close----->fd: 7
[2017-04-07 17:08:46] INFO: client Connect----->fd: 8---0
[2017-04-07 17:08:46] INFO: client Close----->fd: 8
[2017-04-07 17:08:47] INFO: client Connect----->fd: 9---0
[2017-04-07 17:08:47] INFO: client Close----->fd: 9
[2017-04-07 17:08:47] INFO: client Connect----->fd: 10---0
[2017-04-07 17:08:47] INFO: client Close----->fd: 10
[2017-04-07 17:08:49] INFO: client Connect----->fd: 11---0
[2017-04-07 17:08:49] INFO: client Close----->fd: 11
[2017-04-07 17:08:49] INFO: client Connect----->fd: 12---0
原因已找到,是有客户端一直在进行tcp请求,这个客户端是我们配置的阿里云负载均衡器的健康检查,每隔2s运行一次。感谢您的回复!
监听本机公网IP时正常,监听0.0.0.0时不断触发onClose回调:
代码:
日志:
版本: PHP 7.0.3+swoole1.8.6