Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L5: php artisan queue:listen redis connection problem #7904

Closed
dditlev opened this issue Mar 6, 2015 · 8 comments
Closed

L5: php artisan queue:listen redis connection problem #7904

dditlev opened this issue Mar 6, 2015 · 8 comments

Comments

@dditlev
Copy link

dditlev commented Mar 6, 2015

Having moved from L4 to L5 we experience some problems with our queue. We run the queue via redis – which we also use for session, so there should be no problem with our redis connection (we can ping pong on the server via redis-tools aswell)

When we execute the command php artisan queue:listen we get the following exception

[Predis\Connection\ConnectionException]                        
Connection refused [tcp://xxx.xx.x.xx:tcp://xxx.xx.x.xx:6379]

it seems like laravel is trying to connect to [ (tcp://ip) : (tcp://ip) : (port) ], where it should obviously only connect to (tcp://ip) : (port)

I have been unable to locate any descripencies in the various redis/queue related places i've looked.

Thanks in advance!

@dditlev dditlev changed the title php artisan queue:listen php artisan queue:listen redis connection problem Mar 6, 2015
@dditlev dditlev changed the title php artisan queue:listen redis connection problem L5: php artisan queue:listen redis connection problem Mar 6, 2015
@GrahamCampbell
Copy link
Member

Can't replicate. Please make sure you're using the correct dependency versions and have updated your config.

@rgerovski
Copy link

I am also having the same issue! Running Lumen in a php-fpm Docker container. When I run a custom artisan command, it duplicates the connection string:
[Predis\Connection\ConnectionException]
Connection refused [tcp://redis:tcp://172.17.0.2:6379]

However, redis connection works fine when app is accessed from web browser.

@rgerovski
Copy link

I found this to be an issue with the phpdotenv ~v1.0 library. If some environment variable is defined in the OS, and also the same variable is defined in the .env file, phpdotenv gets the system variable by default. This behavior is controlled by the boolean attribute $immutable in Dotenv.php class.

@nicolangr
Copy link

In my case the problem was that the OS environment variable REDIS_PORT was set to

REDIS_PORT=tcp://172.17.0.4:6379
And overwrite the REDIS_PORT set in Laravel .env file.

Maybe Artisan get OS environment variable. I resolved it setting OS environment variable REDIS_PORT to

REDIS_PORT=6379

I use docker and docker-compose so i just modified my docker-compose.yml adding this 2 line:

   environment:
      REDIS_PORT: 6379

@faustienf
Copy link

use host name into .env config,REDIS_HOST=app_redis_1:6379

@Paxxi
Copy link

Paxxi commented Jan 5, 2017

For future reference I ran into this issue yesterday so I'll document it here.

Environment

  • laravel 5.3
  • rancher 1.2.0
  • docker 1.12.2
  • php-fpm 7.0
  • apache
  • mysql
  • redis

Setup

Redis is used in laravel as a queue, cache, session storage.
Mysql is used for db storage.

We have one rancher stack that contains two containers
web: apache+php-fpm+laravel
redis: only runs redis

What went wrong

For it's service discovery rancher will inject a lot of environment variables based on the name of the containers.

  • SERVICENAME_REDIS_1_PORT=tcp://redis:6379
  • SERVICENAME_REDIS_1_PORT_6379_TCP=tcp://redis:6379
  • SERVICENAME_REDIS_1_PORT=tcp://redis:6379
  • SERVICENAME_REDIS_1_PORT_6379_TCP=tcp://redis:6379
  • REDIS_PORT_6379_TCP_ADDR=redis
  • REDIS_PORT_6379_TCP_PORT=6379
  • SERVICENAME_REDIS_1_PORT_6379_TCP_ADDR=redis
  • REDIS_PORT_6379_TCP=tcp://redis:6379
  • SERVICENAME_REDIS_1_PORT_6379_TCP_PROTO=tcp

This ended up overwriting our usage of REDIS_PORT that we set as an environment variable on the container when deploying it.

TLDR

If you're using rancher, avoid environment variables that could match a container/service name in some form, a lot of pain can be avoided that way

@guoxiangke
Copy link

====docker-compose.yml
laravel:
depends_on:
- db
- redis
links:
- db:mysql
- redis
=======.env
.env
REDIS_HOST=redis:6379

works for me

@cooltheo
Copy link

Make sure that the redis service is accessible inside docker. This is my solution.
.env file.
### REDIS CONFIG REDIS_HOST=redis REDIS_PASSWORD=null REDIS_PORT=6379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants