异步 MySQL Redis 阿里云上使用异常,求解!

在本机(mac)上运行正常:

链接配置如下:

$worker->onWorkerStart = function () {
global $mysql;
global $factory;

// 获得workerman的event-loop,
$loop = Worker::getEventLoop();

// Redis
$factory = new Factory($loop);
// 连接参数
$mysql = new React\MySQL\Connection($loop, [
'host' => 'localhost',
'dbname' => DBDATABASE,
'user' => DBUSER,
'passwd' => DBPWD,
]);
$mysql->on('error', function ($e) {
echo $e;
});
$mysql->connect(function ($e) {
if ($e) {
echo $e;
} else {
echo "mysql connect success\n";
}
});

异常报错如下:

exception 'React\Dns\RecordNotFoundException' with message 'DNS Request did not return valid answer.' in /Data/htdocs/SEMAC/Workerman/vendor/react/dns/src/Resolver/Resolver.php:41
Stack trace:
0 /Data/htdocs/SEMAC/Workerman/vendor/react/dns/src/Resolver/Resolver.php(29): React\Dns\Resolver\Resolver->extractAddress(Object(React\Dns\Query\Query), Object(React\Dns\Model\Message))

1 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/FulfilledPromise.php(25): React\Dns\Resolver\Resolver->React\Dns\Resolver{closure}(Object(React\Dns\Model\Message))

2 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(119): React\Promise\FulfilledPromise->then(Object(Closure), NULL)

3 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(174): React\Promise\Promise->React\Promise{closure}(Object(React\Promise\FulfilledPromise))

4 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(133): React\Promise\Promise->settle(Object(React\Promise\FulfilledPromise))

5 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(192): React\Promise\Promise->resolve(Object(React\Dns\Model\Message))

6 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/FulfilledPromise.php(39): React\Promise\Promise->React\Promise{closure}(Object(React\Dns\Model\Message))

7 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(120): React\Promise\FulfilledPromise->done(Object(Closure), Object(Closure), Object(Closure))

8 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(174): React\Promise\Promise->React\Promise{closure}(Object(React\Promise\FulfilledPromise))

9 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(133): React\Promise\Promise->settle(Object(React\Promise\FulfilledPromise))

10 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(192): React\Promise\Promise->resolve(Object(React\Dns\Model\Message))

11 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/FulfilledPromise.php(39): React\Promise\Promise->React\Promise{closure}(Object(React\Dns\Model\Message))

12 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(120): React\Promise\FulfilledPromise->done(Object(Closure), Object(Closure), Object(Closure))

13 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(174): React\Promise\Promise->React\Promise{closure}(Object(React\Promise\FulfilledPromise))

14 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(133): React\Promise\Promise->settle(Object(React\Promise\FulfilledPromise))

15 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Promise.php(192): React\Promise\Promise->resolve(Object(React\Dns\Model\Message))

16 [internal function]: React\Promise\Promise->React\Promise{closure}(Object(React\Dns\Model\Message))

17 /Data/htdocs/SEMAC/Workerman/vendor/react/promise/src/Deferred.php(35): call_user_func(Object(Closure), Object(React\Dns\Model\Message))

18 /Data/htdocs/SEMAC/Workerman/vendor/react/dns/src/Query/Executor.php(94): React\Promise\Deferred->resolve(Object(React\Dns\Model\Message))

19 [internal function]: React\Dns\Query\Executor->React\Dns\Query{closure}('\x02\v\x81\x83\x00\x01\x00\x00\x00\x01\x00\x00\tlo...', Object(React\Socket\Connection))

20 /Data/htdocs/SEMAC/Workerman/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(65): call_user_func_array(Object(Closure), Array)

21 /Data/htdocs/SEMAC/Workerman/vendor/react/stream/src/Stream.php(170): Evenement\EventEmitter->emit('data', Array)

22 [internal function]: React\Stream\Stream->handleData(Resource id #62, Object(Workerman\Events\React\StreamSelectLoop))

23 /Data/htdocs/SEMAC/Workerman/vendor/react/event-loop/src/StreamSelectLoop.php(232): call_user_func(Array, Resource id #62, Object(Workerman\Events\React\StreamSelectLoop))

24 /Data/htdocs/SEMAC/Workerman/vendor/react/event-loop/src/StreamSelectLoop.php(201): React\EventLoop\StreamSelectLoop->waitForStreamActivity(997540.95077515)

25 /Data/htdocs/SEMAC/Workerman/Events/React.php(98): React\EventLoop\StreamSelectLoop->run()

26 /Data/htdocs/SEMAC/Workerman/Worker.php(1521): Workerman\Events\React->loop()

27 /Data/htdocs/SEMAC/Workerman/Worker.php(932): Workerman\Worker->run()

28 /Data/htdocs/SEMAC/Workerman/Worker.php(895): Workerman\Worker::forkOneWorker(Object(Workerman\Worker))

29 /Data/htdocs/SEMAC/Workerman/Worker.php(427): Workerman\Worker::forkWorkers()

30 /Data/htdocs/SEMAC/server.php(414): Workerman\Worker::runAll()

exception 'React\Dns\Query\TimeoutException' with message 'DNS query for localhost timed out' in /Data/htdocs/SEMAC/Workerman/vendor/react/dns/src/Query/Executor.php:69
Stack trace:
0 [internal function]: React\Dns\Query\Executor->React\Dns\Query{closure}(Object(React\EventLoop\Timer\Timer))

1 /Data/htdocs/SEMAC/Workerman/vendor/react/event-loop/src/Timer/Timers.php(90): call_user_func(Object(Closure), Object(React\EventLoop\Timer\Timer))

2 /Data/htdocs/SEMAC/Workerman/vendor/react/event-loop/src/StreamSelectLoop.php(177): React\EventLoop\Timer\Timers->tick()

3 /Data/htdocs/SEMAC/Workerman/Events/React.php(98): React\EventLoop\StreamSelectLoop->run()

4 /Data/htdocs/SEMAC/Workerman/Worker.php(1521): Workerman\Events\React->loop()

5 /Data/htdocs/SEMAC/Workerman/Worker.php(932): Workerman\Worker->run()

6 /Data/htdocs/SEMAC/Workerman/Worker.php(895): Workerman\Worker::forkOneWorker(Object(Workerman\Worker))

7 /Data/htdocs/SEMAC/Workerman/Worker.php(427): Workerman\Worker::forkWorkers()

8 /Data/htdocs/SEMAC/server.php(414): Workerman\Worker::runAll()

9 {main}
2017-01-09 16:19 添加评论 分享
已邀请:
0

mrzeta - meetrue.com

赞同来自:

'host' => 'localhost', 改成正确的地址!
0

walkor

赞同来自:

嗯,改成具体的ip地址。
另外这个是第三方的异步mysql redis库,建议用pdo_mysql redis 扩展。

要回复问题请先登录注册

退出全屏模式 全屏模式 回复