GlobalData的client 隔一段时间会抛出错误

stephen

配置应该没有问题,都是在本机的,否则不会偶尔出问题,这个业务是监控数据的,难道是连接太频繁导致?

PHP Warning:  stream_socket_client(): unable to connect to tcp://127.0.0.1:2207 (Cannot assign requested address) in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php on line 66

Warning: stream_socket_client(): unable to connect to tcp://127.0.0.1:2207 (Cannot assign requested address) in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php on line 66
exception 'Exception' with message 'Cannot assign requested address' in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php:69
Stack trace:
#0 /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php(138): GlobalData\Client->getConnection('depth')
#1 /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php(113): GlobalData\Client->__get('depth')
#2 /vagrant/Quant/bootstrap/watcher/lib/watcher.php(84): GlobalData\Client->__isset('depth')
#3 /vagrant/Quant/bootstrap/watcher/lib/watcher.php(59): Watcher->sendToClient(Array, Array)
#4 : Watcher->HttpWatcher(Array)
#5 /vagrant/Quant/bootstrap/watcher/start_watcher.php(25): call_user_func_array(Array, Array)
#6 : {closure}(Object(Workerman\Worker))
#7 /vagrant/Quant/src/vendor/workerman/workerman/Worker.php(1556): call_user_func(Object(Closure), Object(Workerman\Worker))
#8 /vagrant/Quant/src/vendor/workerman/workerman/Worker.php(959): Workerman\Worker->run()
#9 /vagrant/Quant/src/vendor/workerman/workerman/Worker.php(922): Workerman\Worker::forkOneWorker(Object(Workerman\Worker))
#10 /vagrant/Quant/src/vendor/workerman/workerman/Worker.php(430): Workerman\Worker::forkWorkers()
#11 /vagrant/Quant/bootstrap/start.php(20): Workerman\Worker::runAll()
#12 {main}
PHP Fatal error:  Uncaught exception 'Exception' with message 'Cannot assign requested address' in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php:69
Stack trace:
#0 /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php(138): GlobalData\Client->getConnection('depth')
#1 /vagrant/Quant/bootstrap/trader/lib/TradeRange.php(13): GlobalData\Client->__get('depth')
#2 /vagrant/Quant/bootstrap/trader/lib/TradeRange.php(76): TradeRange->getDepth()
#3 /vagrant/Quant/bootstrap/trader/strategies/StrategyETH.php(60): TradeRange->getTradeableData()
#4 : StrategyETH->analysis()
#5 /vagrant/Quant/src/vendor/workerman/workerman/Events/React/ExtEventLoop.php(68): call_user_func_array(Array, Array)
#6 : Workerman\Events\React\ExtEventLoop->Workerman\Events\React\{closure}(Object(React\EventLoop\Timer\Timer))
#7 /vagrant/Quant/src/vendor/react/event-loop/src/ExtEventLoop.php(298): call_user_func(Object(Closure), Object(React\EventLoop\Timer\Timer))
#8 : React\EventLoop in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php on line 69

Fatal error: Uncaught exception 'Exception' with message 'Cannot assign requested address' in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php:69
Stack trace:
#0 /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php(138): GlobalData\Client->getConnection('depth')
#1 /vagrant/Quant/bootstrap/trader/lib/TradeRange.php(13): GlobalData\Client->__get('depth')
#2 /vagrant/Quant/bootstrap/trader/lib/TradeRange.php(76): TradeRange->getDepth()
#3 /vagrant/Quant/bootstrap/trader/strategies/StrategyETH.php(60): TradeRange->getTradeableData()
#4 : StrategyETH->analysis()
#5 /vagrant/Quant/src/vendor/workerman/workerman/Events/React/ExtEventLoop.php(68): call_user_func_array(Array, Array)
#6 : Workerman\Events\React\ExtEventLoop->Workerman\Events\React\{closure}(Object(React\EventLoop\Timer\Timer))
#7 /vagrant/Quant/src/vendor/react/event-loop/src/ExtEventLoop.php(298): call_user_func(Object(Closure), Object(React\EventLoop\Timer\Timer))
#8 : React\EventLoop in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php on line 69
Worker process terminated with E_ERROR "Uncaught exception 'Exception' with message 'Cannot assign requested address' in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php:69
Stack trace:
#0 /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php(138): GlobalData\Client->getConnection('depth')
#1 /vagrant/Quant/bootstrap/trader/lib/TradeRange.php(13): GlobalData\Client->__get('depth')
#2 /vagrant/Quant/bootstrap/trader/lib/TradeRange.php(76): TradeRange->getDepth()
#3 /vagrant/Quant/bootstrap/trader/strategies/StrategyETH.php(60): TradeRange->getTradeableData()
#4 : StrategyETH->analysis()
#5 /vagrant/Quant/src/vendor/workerman/workerman/Events/React/ExtEventLoop.php(68): call_user_func_array(Array, Array)
#6 : Workerman\Events\React\ExtEventLoop->Workerman\Events\React\{closure}(Object(React\EventLoop\Timer\Timer))
#7 /vagrant/Quant/src/vendor/react/event-loop/src/ExtEventLoop.php(298): call_user_func(Object(Closure), Object(React\EventLoop\Timer\Timer))
#8 : React\EventLoop in /vagrant/Quant/src/vendor/workerman/globaldata/src/Client.php on line 69"
Worker process terminated with exit()/die(). Please do not call exit()/die() in workerman.
worker exit with status 65280
worker exit with status 64000
阅读 2183
3个回答

walkor

没有优化linux内核导致的,参考http://doc.workerman.net/315302。

  • stephen 2017-08-06

    谢谢,我调试一下试试。

stephen

优化了内核问题仍然会有,连接服务器的时候使用了单例方法,观察了十几个小时,没再有问题了,发出来给后面遇到类似问题的人参考

static private $globalData;

static public function getGlobalData()
{
    if(self::$globalData===null) {
        self::$globalData = new GlobalData\Client('127.0.0.1:2207');
    }
    return self::$globalData;
}
  • 暂无评论
walkor

必须单例啊,不然不停的创建连接,本地端口都耗费光了,就报Cannot assign requested address错误了

  • stephen 2017-08-10

    是的,直接从手册拷贝的,大意了