On Heroku, I'm running Laravel 8. For background activities, I'm utilizing the Laravel Queue. Everything worked OK before, but now I'm getting an error:
The [database] queue connection is not configured
My queue configurations
return [
'default' => env('QUEUE_DRIVER', 'database'),
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 700,
'after_commit' => false,
'timeout' => 180,
],
I have run composer dump and I have cleared all application cache but it's not working, how can I fix this?
Related
We have Horizon running for quite some time now, and have no issues with it.
But after our most recent deploy on production, it remains inactive and there are no workers being started.
I fail to see the problem, nor do we get any errors logged into bugsnag, so I'm a bit lost here.
What would be the best way to debug issues with Horizon? I have verified, and I can talk to redis. The dashboard also displays jobs on the queue, so it's just a matter of the workers not being started.
We're setting up our instances using Laravel forge, and I can confirm that there is a daemon that runs php artisan horizon in the correct directory. Running that command manually on the server also doesn't give me much info that I can work with.
I'm sure here must be SOME error, but it's not beig caught / displayed / whatever. Any thoughts on how to properly debug this?
This is the contents of config/horizon.php:
<?php
return [
'use' => 'default',
'waits' => [
'redis:default' => 60,
],
'environments' => [
'dev' => [
'all-prio' => [
'connection' => 'redis',
'queue' => ['default', 'high', 'medium', 'low'],
'balance' => 'auto',
'processes' => 10,
'tries' => 3,
],
],
'acc' => [
'all-prio' => [
'connection' => 'redis',
'queue' => ['default', 'high', 'medium', 'low'],
'balance' => 'auto',
'processes' => 10,
'tries' => 3,
],
],
'production' => [
'high-prio' => [
'connection' => 'redis',
'queue' => ['high'],
'balance' => 'auto',
'processes' => 10,
'tries' => 5,
],
'default-prio' => [
'connection' => 'redis',
'queue' => ['medium', 'default'],
'balance' => 'auto',
'processes' => 10,
'tries' => 3,
],
'low-prio' => [
'connection' => 'redis',
'queue' => ['low'],
'balance' => 'auto',
'processes' => 5,
'tries' => 3,
],
],
],
];
The environment is correctly being set to 'production' on that environment.
This is the contents of the config/database.php redis section:
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
]
I've setup a redis cluster with 6 nodes locally on my ubuntu 18.04, starting from 127.0.0.1:7000 to 127.0.0.1:7006, with the default 'utils/create-cluster' script that comes with redis binaries.
I'm having issues setting up redis on a laravel 5.7 application, I'm trying to make a request to an endpoint and I'm getting the following error
No connections available in the pool at line 337
myApp/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php
It's exactly the same error from here --> Predis with laravel 5.5 "No connections available in the pool in Aggregate/RedisCluster.php:337 "
But that answer has not solved my issue, nor the referred link --> https://github.com/nrk/predis/issues/480
My .env file has the following values
BROADCAST_DRIVER=log
CACHE_DRIVER=redis
QUEUE_CONNECTION=sync
SESSION_DRIVER=redis
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=7000
And my app/database.php is as follows
'redis' => [
'client' => 'predis',
'cluster' => true,
'options' => [
'cluster' => 'redis',
],
'clusters' => [
'default' => [
[
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DB', 0),
],
],
'cache' => [
[
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_CACHE_DB', 1),
],
]
],
],
I'd appreciate some help!
After a lot of googling and trial and error, I managed to solve the problem by changing the file config/cache.php at the following lines
error:
'redis' => [
'driver' => 'redis'
'connection' => 'cache'
]
working:
'redis' => [
'driver' => 'redis'
'connection' => 'default'
]
I am trying to use redis for caching in laravel.
I have install redis locally and I know it is working as I am able to run horizon queues and workers.
I also get a response when doing
redis-cli PING
but when I try this code
$user = Cache::get('User:' .$Id , function ($Id) {
return User::where('id', '=', $Id)->firstOrFail();
});
I get the error
Redis connection [cache] not configured.
I have changed my .env to have the following entry
CACHE_DRIVER=redis
Find this in cache.php
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
],
and change it to:
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
can u set redis configration in config/database.php like this
'redis' => [
'client' => 'predis',
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', 'footbar'), //if password otherwise set null
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
other wise set in .env file
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
then run artisan command
php artisan config:cache
php artisan config:clear
step 1 : Configuration : config/database.php add below array
'redis' => array(
'cluster' => false,
'default' => array(
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env(‘REDIS_DATABASE',0),
),
),
Step 2 : Configuration : .env file
CACHE_DRIVER=redis
REDIS_DATABASE=0
Step 3 : Config/cache.php
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
Additionally to other answer and in case that you use the redis as queue driver, verify that redis connection is set to "default" in the queue.phpconfiguration file.
I used redis for task queue in laravel, i want to use connection name per queue to handle config varibales conflict in queue in below code :
php artisan queue:work connection-name --deamon --queue=high,medium,low --sleep=3 --tries=3
But i dont know what is the connection name in below code to use:
'default' => env('QUEUE_DRIVER', 'redis'),
'connections' => [
'sync' => [
'driver' => 'sync',
],
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'expire' => 60,
],
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'ttr' => 60,
],
'sqs' => [
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
'queue' => 'your-queue-name',
'region' => 'us-east-1',
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'expire' => 60,
],
],
You have several connections configured.
Each connection is an element in the connections array and you just need to pass the relevant key as the name.
e.g.
php artisan queue:work sqs --daemon --queue=high --sleep=3 --tries=3
This question already has answers here:
Using Redis for Queues for Multiple Laravel Applications on a Single Server
(4 answers)
Closed 4 years ago.
I have two project on same server (Ubuntu 16.04) with different database, username and also different user_password.
But if A project's queue failed, it may insert into B project's failed-job table.
Yes, it means sometimes it insert the failed record into the right place.
I checked the Laravel config all with default setting.
I use the supervisor keep walker.
So, anybody has the same problem and a solution for that?
I open an issue on github here. https://github.com/laravel/framework/issues/14403
By author's reply. I'v solved the problem by this two steps:
1.change the config/cache.php
'prefix' => 'myProjectName', //the default value is laravel.
2.change the config/database.php
'redis' => [
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 2, //the default is 0
],
],
You should also pay attention to config/queue.php, if your queue may have more than 60 seconds to finish the job.
'redis' => [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'expire' => 120, //the default is 60, and would be your like.
],
If you want to resolve the conflict by specifying a prefix for the redis connection rather than by using different databases you can do so with the following config.
For predis (the default client)
'redis' => [
'client' => 'predis',
'cluster' => false,
'options'=>[
'prefix' => 'YOUR_PREFIX_HERE'
],
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
For phpredis client (available since Laravel 5.3):
'redis' => [
'cluster' => false,
'client' => 'phpredis',
'default' => [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
'prefix' => 'YOUR_PREFIX_HERE:',
],
],