今天中午發(fā)生了這個(gè)事件,一直調(diào)試無(wú)果
大約持續(xù)了1個(gè)小時(shí) 又恢復(fù)正常,然后剛剛16點(diǎn)整的樣子又出現(xiàn)了這個(gè)情況 并且現(xiàn)在還未成功恢復(fù)
workerman status正常 并且瀏覽器只發(fā)了一個(gè)包
同服務(wù)器的另外一個(gè)網(wǎng)站(基本上一樣的代碼同樣的配置未出現(xiàn)標(biāo)題中的情況)
用的端口1031 接收端口 1032 發(fā)送端口
這個(gè)是使用的代碼
<?php
?
ini_set('memory_limit', '1024M');
?
use Workerman\Worker;
?
use Workerman\Lib\Timer;
?
use PHPSocketIO\SocketIO;
?
?
?
include __DIR__ . '/vendor/autoload.php';
?
?
?
$online_uid_list = array();
?
?
?
$sender_io = new SocketIO(1031);
?
$sender_io->count = 8;
?
?
?
$sender_io->on('connection', function($socket){
?
?
?
$socket->on('login', function ($data, $data2 = '') use($socket){
?
if(isset($socket->uid)) return;
?
?
?
if(isset($data)) $uid = $data;
?
else $uid = $data.'_'.$data2;
?
?
?
global $online_uid_list;
?
$uid = (string)$uid;
?
$online_uid_list = array();
?
?
?
$socket->join($uid);
?
$socket->uid = $uid;
?
$socket->join('user');
?
send_visitor_count();
?
});
?
?
?
$socket->on('admin_login', function ($data) use($socket){
?
if(isset($socket->uid)) return;
?
?
?
$uid = $data;
?
$socket->join($uid);
?
$socket->uid = $uid;
?
$socket->join('admin');
?
});
?
?
?
$socket->on('send_my_tid', function ($tid) use($socket){
?
global $online_uid_list, $sender_io;
?
$online_uid_list = $tid;
?
if($tid != '')
?
{
?
$socket->join('group_'.$tid);
?
}
?
});
?
?
?
$socket->on('where_i_from', function ($from) use($socket){
?
global $online_uid_list, $sender_io;
?
$online_uid_list = $from;
?
});
?
?
?
$socket->on('send_my_cid', function ($cid) use($socket){
?
global $online_uid_list, $sender_io;
?
$online_uid_list = $cid;
?
if($cid != '')
?
{
?
$socket->join('group_'.$cid);
?
$sender_io->to('admin_'.$cid)->emit('update_visitor_list', $socket->uid);
?
}
?
else
?
{
?
$sender_io->to('admin')->emit('update_visitor_list', $socket->uid);
?
}
?
});
?
?
?
$socket->on('get_my_visitor', function ($cid) use($socket){
?
global $online_uid_list, $sender_io;
?
$result = array();
?
foreach($online_uid_list as $k => $v)
?
{
?
if( isset($v) AND ($v == $cid OR $v == '') ) $result[] = $k;
?
}
?
$sender_io->to('admin_'.$cid)->emit('update_visitor_list', join(',', $result));
?
});
?
?
?
$socket->on('get_all_visitor', function (){
?
global $online_uid_list, $sender_io;
?
$sender_io->to('admin')->emit('get_all_visitor', json_encode($online_uid_list));
?
});
?
?
?
$socket->on('get_visitor_count', function (){
?
send_visitor_count();
?
});
?
?
?
$socket->on('disconnect', function () use($socket){
?
if(!isset($socket->uid)) return;
?
global $online_uid_list;
?
?
?
$info = explode('_', $socket->uid);
?
if($info != 'admin' AND isset($online_uid_list))
?
{
?
global $sender_io;
?
$sender_io->to('admin_'.$online_uid_list)->emit('visitor_leave', $socket->uid);
?
}
?
?
?
unset($online_uid_list);
?
?
?
send_visitor_count();
?
});
?
?
?
});
?
?
?
?
?
$sender_io->on('workerStart', function (){
?
$inner_http_worker = new Worker('http://0.0.0.0:1032');
?
$inner_http_worker->onMessage = function($http_connection, $data){
?
$_POST = $_POST ? $_POST : $_GET;
?
global $sender_io;
?
$to = isset($_POST) ? $_POST : false;
?
if($to)
?
{
?
$to = explode('|', $to);
?
foreach($to as $v)
?
{
?
$sender_io->to($v)->emit($_POST, $_POST);
?
}
?
return $http_connection->send('ok');
?
}
?
else
?
{
?
? ? ? ? ? ? if(isset($_POST)){
?
? ? ? ? ? ? ? ? $sender_io->emit($_POST, $_POST);
?
? ? ? ? ? ? ? ? return $http_connection->send('ok');
?
? ? ? ? ? ? }
?
}
?
return $http_connection->send('fail');
?
};
?
$inner_http_worker->listen();
?
?
?
});
?
?
?
function send_visitor_count()
?
{
?
global $online_uid_list, $sender_io;
?
$sender_io->to('user')->emit('get_visitor_count', count($online_uid_list));
?
}
?
?
?
?
?
if(!defined('GLOBAL_START'))
?
{
?
Worker::runAll();
}
```?