hhxsv5 / laravel-s

LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.
MIT License
3.83k stars 473 forks source link

redis 过10几分钟后连接不上了 请帮助一下我 #207

Closed erdong01 closed 4 years ago

erdong01 commented 4 years ago
| Software | Version |
| --------- | --------- |
| PHP | 7.3.11-1+ubuntu18.04.1+deb.sury.org+1 |
| Swoole | `4.4.12` |
| Laravel | `5.5.48` |
| LaravelS | `3.5.14` |
  1. Detail description about this issue(error/log)
{
    "context":{
        "exception":{
            "class":"RedisException",
            "message":"Connection refused",
            "code":0,
            "file":"/var/www/code/api.laravel/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:96"
        }
    },
    "level":400,
    "level_name":"ERROR",
    "channel":"local",
    "datetime":{
        "date":"2019-11-22 17:53:25.961116",
        "timezone_type":3,
        "timezone":"Asia/Shanghai"
    },
    "extra":{
        "file":"App\Exceptions\Handler->report:39",
        "line":39,
        "ip":"192.168.31.85",
        "url":"[POST]http://oa-api.517rxt.test/v1/auth/login"
    },
    "message_string":"Connection refused",
    "@timestamp":"2019-11-22T17:53:25+08:00",
    "trace_id":0
}

第二次在请求

{
    "context":{
        "exception":{
            "class":"RedisException",
            "message":"NOAUTH Authentication required.",
            "code":0,
            "file":"/var/www/code/api.laravel/vendor/laravel/framework/src/Illuminate/Redis/Connections/PhpRedisConnection.php:32"
        }
    },
    "level":400,
    "level_name":"ERROR",
    "channel":"local",
    "datetime":{
        "date":"2019-11-26 16:46:57.673060",
        "timezone_type":3,
        "timezone":"Asia/Shanghai"
    },
    "extra":{
        "file":"App\Exceptions\Handler->report:39",
        "line":39,
        "ip":"192.168.31.85",
        "url":"[POST]http://tmr-api.517rxt.test/v1/auth/login?XDEBUG_SESSION_START=14915"
    },
    "message_string":"NOAUTH Authentication required.",
    "@timestamp":"2019-11-26T16:46:57+08:00",
    "trace_id":0
}
  1. Give us a reproducible code block and steps

 'redis' => [

        'client' => env('REDIS_CLIENT', 'phpredis'),
        'options'=>[
            'timeout'=>8*3600,
            'read_timeout'=>8*3600,
            'read_write_timeout'=>8*3600,
            'persistent'=>true
        ],
        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
            'timeout'=>8*3600,
            'read_timeout'=>8*3600,
            'read_write_timeout'=>8*3600,
            'persistent'=>true
        ],
    ],
boyfoo commented 4 years ago

我也遇到这个问题了

hhxsv5 commented 4 years ago

请上传一个可重现例子到这里。

erdong01 commented 4 years ago

请上传一个可重现例子到这里。

不清楚要什么例子 就这样使用框架 请求一个空逻辑api请求也是会出现redis断开

erdong01 commented 4 years ago

我今天把php 升级7.4了 还是会出现redis 隔几分钟断开 php.ini 没有做如何改动

hhxsv5 commented 4 years ago

装了Xdebug? 我本地未复现此问题,Swoole不兼容Xdebug,请先关闭Xdebug扩展,然后再试。

erdong01 commented 4 years ago

没有装xdebug 装了都跑不起来了

hhxsv5 commented 4 years ago

我看到你URL上带了XDEBUG_SESSION_START参数,像是用了Xdebug

erdong01 commented 4 years ago

那是以前fpm模型下的 postman上遗留的没删掉 xdebug扩展都没启用 xdebug扩展启用了swoole会直接报错

erdong01 commented 4 years ago

redis 扩展版本


redis

Redis Support => enabled
Redis Version => 5.1.1
Available serializers => php, json

Directive => Local Value => Master Value
redis.arrays.algorithm => no value => no value
redis.arrays.auth => no value => no value
redis.arrays.autorehash => 0 => 0
redis.arrays.connecttimeout => 0 => 0
redis.arrays.consistent => 0 => 0
redis.arrays.distributor => no value => no value
redis.arrays.functions => no value => no value
redis.arrays.hosts => no value => no value
redis.arrays.index => 0 => 0
redis.arrays.lazyconnect => 0 => 0
redis.arrays.names => no value => no value
redis.arrays.pconnect => 0 => 0
redis.arrays.previous => no value => no value
redis.arrays.readtimeout => 0 => 0
redis.arrays.retryinterval => 0 => 0
redis.clusters.auth => no value => no value
redis.clusters.cache_slots => 0 => 0
redis.clusters.persistent => 0 => 0
redis.clusters.read_timeout => 0 => 0
redis.clusters.seeds => no value => no value
redis.clusters.timeout => 0 => 0
redis.pconnect.connection_limit => 0 => 0
redis.pconnect.pooling_enabled => 1 => 1
redis.session.lock_expire => 0 => 0
redis.session.lock_retries => 10 => 10
redis.session.lock_wait_time => 2000 => 2000
redis.session.locking_enabled => 0 => 0
hhxsv5 commented 4 years ago

我跟你的环境各个版本都一致,但也没有重现。 image image

你执行下php -m列出所有扩展,然后上传一个可复现问题的代码压缩包到这里吧。

erdong01 commented 4 years ago
root@ubuntu:/var/www/code/api.laravel# php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dba
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
Phar
posix
pspell
readline
redis
Reflection
session
shmop
SimpleXML
snmp
soap
sockets
sodium
SPL
standard
swoole
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

composer


{
  "name": "laravel/laravel",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "type": "project",
  "require": {
    "php": ">=7.1.0",
    "barryvdh/laravel-cors": "^0.11.0",
    "dingo/api": "2.0.0-alpha2",
    "elasticquent/elasticquent": "=v1.0.7",
    "fideloper/proxy": "~4.0",
    "hhxsv5/laravel-s": "~3.5",
    "jaeger/phpquery-single": "^0.9.9",
    "laravel/framework": "5.5.*",
    "laravel/tinker": "~1.0",
    "maatwebsite/excel": "^3.1",
    "marstm/bean": "^0.0.3",
    "overtrue/laravel-wechat": "~4.0",
    "tymon/jwt-auth": "dev-develop",
    "vinkla/hashids": "v3.3.0",
    "yansongda/laravel-pay": "v2.1.0",
    "zgldh/qiniu-laravel-storage": "^0.10.0"
  },
  "require-dev": {
    "barryvdh/laravel-ide-helper": "dev-master",
    "doctrine/dbal": "^2.9",
    "eaglewu/swoole-ide-helper": "dev-master",
    "filp/whoops": "~2.0",
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "~1.0",
    "phpunit/phpunit": "~6.0",
    "squizlabs/php_codesniffer": "3.*",
    "symfony/thanks": "^1.0"
  },
  "autoload": {
    "classmap": [
      "database/seeds",
      "database/factories"
    ],
    "psr-4": {
      "App\\": "app/"
    },
    "files": [
      "app/Helpers/Functions.php"
    ]
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    }
  },
  "extra": {
    "laravel": {
      "dont-discover": [
      ]
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@php artisan key:generate"
    ],
    "post-autoload-dump": [
      "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
      "@php artisan package:discover"
    ]
  },
  "config": {
    "preferred-install": "dist",
    "sort-packages": true,
    "optimize-autoloader": true,
    "secure-http": false
  },
  "repositories": {
    "packagist": {
      "type": "composer",
      "url": "https://mirrors.aliyun.com/composer/"
    }
  }
}

我搭建框架 请求空控制器 没有如何逻辑代码 隔几分钟就回连接不上redis

erdong01 commented 4 years ago

Route::get('/', function () {
    \Illuminate\Support\Facades\Cache::store('redis')->add('test', "2222322234",60);
    $res=   \Illuminate\Support\Facades\Cache::store('redis')->get('test');
    return $res;
});

这是代码段

erdong01 commented 4 years ago

放弃了啊

hhxsv5 commented 4 years ago

没有重现,目前只有你反馈有问题,新建个项目,上传可重现问题的压缩包吧。

linzi007 commented 4 years ago

NOAUTH Authentication required. 正常运行过程中,出现了这个异常