“Connection refused” while php can connect
-
Hi!
The plugin shows a connection refused, when i copy the connection code to a simple PHP file, the file can connect to redis…
Status: Niet verbonden Client: PhpRedis (v5.3.2) Drop-in: Valid Disabled: No Ping: Errors: [ "Connection refused" ] PhpRedis: 5.3.2Code copied from plugin to separate file which successfully connects:
connect_using_phpredis($parameters); function connect_using_phpredis( $parameters ) { $version = phpversion( 'redis' ); $redis = null; $redis = new Redis(); $args = [ 'host' => $parameters['host'], 'port' => $parameters['port'], 'timeout' => $parameters['timeout'], '', 'retry_interval' => (int) $parameters['retry_interval'], ]; if ( strcasecmp( 'tls', $parameters['scheme'] ) === 0 ) { $args['host'] = sprintf( '%s://%s', $parameters['scheme'], str_replace( 'tls://', '', $parameters['host'] ) ); } if ( strcasecmp( 'unix', $parameters['scheme'] ) === 0 ) { $args['host'] = $parameters['path']; $args['port'] = -1; } if ( version_compare( $version, '3.1.3', '>=' ) ) { $args['read_timeout'] = $parameters['read_timeout']; } call_user_func_array( [ $redis, 'connect' ], array_values( $args ) ); if ( isset( $parameters['password'] ) ) { $args['password'] = $parameters['password']; $redis->auth( $parameters['password'] ); } if ( isset( $parameters['database'] ) ) { if ( ctype_digit( (string) $parameters['database'] ) ) { $parameters['database'] = (int) $parameters['database']; } $args['database'] = $parameters['database']; if ( $parameters['database'] ) { $redis->select( $parameters['database'] ); } } var_dump($redis->ping('test')); }string(4) "test"
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘“Connection refused” while php can connect’ is closed to new replies.