通过协程获取redis内容时,为什么连接不上redis了

来源:6-7 Swoole 协程精讲-基于2.x(下)

慕仰7809215

2018-04-13

写回答

3回答

慕仰7809215

提问者

2018-04-15


$http=new swoole_http_server('0.0.0.0',8811);
$http->on('request',function ($request,$response){
   //获取redis里面的key的内容,然后输出到浏览器
   $redis = new Swoole\Coroutine\Redis();
   $redis->connect('127.0.0.1', 6379);
   $value=$redis->get($request->get['xiaosong']);
   $response->header('Content-type','text/plain');
   $response->end($value);
});
$http->start();

0
0

慕仰7809215

提问者

2018-04-15



PHP Fatal error:  Uncaught Error: Maximum function nesting level of '256' reached, aborting! in /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:18

Stack trace:

#0 [internal function]: Swoole\Coroutine\Redis->close()

#1 /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php(18): Swoole\Coroutine\Redis->__destruct()

#2 {main}


Next Error: Maximum function nesting level of '256' reached, aborting! in /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:0

Stack trace:

#0 [internal function]: Swoole\Http\Response->end()

#1 /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php(18): Swoole\Http\Response->__destruct()

#2 {main}


Next Error: Maximum function nesting level of '256' reached, aborting! in /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:0

Stack trace:

#0 [internal function]: Swoole\Coroutine\Redis->close()

#1 /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php(18): Swoole\Coroutine\Redis->__destruct()

#2 {main}

  thrown in /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php on line 0

PHP Stack trace:

PHP   1. {main}() /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:0

PHP   2. Swoole\Http\Server->start() /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:24

PHP   3. {closure:/home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:16-23}() /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:0

PHP   4. Swoole\Coroutine\Redis->connect() /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:19

PHP   5. {closure:/home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:16-23}() /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:0

PHP   6. Swoole\Coroutine\Redis->connect() /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:19

PHP   7. {closure:/home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:16-23}() /home/wwwroot/default/swoole_mooc/demo/coroutine/redis.php:0


0
2
weixin_慕村2369771
#0 [internal function]: Swoole\Coroutine\Redis->close() 你关闭了 redis ,需要开启
2019-03-17
共2条回复

singwa

2018-04-13

您好。代码贴下,以及你那边的错误信息帖下。

0
0

Swoole入门到实战打造高性能赛事直播平台

swoole创始人推荐,借助Swoole打造高性能直播平台

2228 学习 · 1062 问题

查看课程