Few days back, We implemented AWS auto scaling and after that we started facing automatic logout problem in Laravel, We changed session storing from file to database like this
BROADCAST_DRIVER=redis
CACHE_DRIVER=file
SESSION_DRIVER=redis
QUEUE_DRIVER=database
REDIS_HOST=<Private IP of MYSQL + REDIS server>
REDIS_PASSWORD=null
REDIS_PORT=6379
Following is our server architecture.
As a solution, I increased session lifetime in config/session.php, which is not a good solution and it did not work. I tried to find cause in code as well but I could not find any clue.
This problem is huge in my website right now. Can anyone suggest what could be the problem and possible solutions?
Related
I have a fairly basic laravel site. Everytime Envoyer runs and deploys the site, I get a ton (150+) errors that say this:
InvalidArgumentException [...redacted project dir...]/current/artisan queue:work sqs --tries=5
The [sqs] queue connection has not been configured.
I'm not even using SQS so I have no idea where the error is coming from. Only deployment hooks I have in Envoyer that might be related are these:
My .env looks like this with things regarding the drivers and queue and such:
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=database
SESSION_LIFETIME=120
I'm lost here. Any help would be greatly appreciated! If you need to see anything else please let me know.
I have a Laravel 5.5 app using Stripe for subscriptions, deployed on Forge/Digital Ocean.
Everything has been working fine for many months, but today both environmental variables env('PUB_STRIPE_API_KEY') and env('STRIPE_API_KEY') are showing as not present (if(empty) is coming up true for both variables) and Stripe functionality is therefore stopped. Both are present and accounted for in my .ENV file.
STRIPE_API_KEY=sk_test_fPpKzHV49vImGOh4Aqxxxxxx
PUB_STRIPE_API_KEY=pk_test_HrVhWbsRL90qm7RrCbxxxxxx
However, my identical local development instance works just fine. Both were just fine a few days ago and no changes have been made to any Stripe or .ENV code. I'm perplexed.
Other .ENV variables, such as database connection parameters, all seem fine. Only Stripe is effected.
I have checked the .ENV file. I have cleared cache (php artisan cache:clear). No difference. I don't know where to go from here. Any suggestions...?
So, after days of chasing ghost solutions a simple artisan config:clear solved the issue. The glitch was on the Forge/Digital Ocean end, not my code. I had already tried artisan cache:clear thinking that would resolve what (correctly) appeared to be a caching issue, but I was using the wrong artisan cache clearing command. All good now and back working again :)
Im running a new Laravel project and getting this error ,"You're using the default database name laravel. This database does not exist. Edit the .env file and use the correct database name in the DB_DATABASE key.", But what's confusing is, its not the first time running a Laravel project,but I have never encountered such. Anyone to help?. Thanks in advance.
I had to reset the configuration in my PhpStorm, it was calling for PHP 7.4 yet my installed version was 7.2. Thanks to those who responded, I appreciate.
There are two options;
If you are using Homestead then you need to configure your database connection as thus;
DB_DATABASE=name_of_database
DB_USERNAME=homestead
DB_PASSWORD=secret
If your environment is out of Homestead, then use the credentials you use when logging in to localhost/phpmyadmin
I hope it helps.
I just learned about Redis and I want to try create a scalable Web Application, to achieve this I'm going to use Laravel as the main and Lumen as the microservice (API). So after I learned about Redis, I want to add it to my project, but I confused and tried to get a explanation from google, but no luck. I still confused after read a lot of tutorials.
My questions are:
Should I make it separated from the server? (because I saw it on
Docker, redis will be on separated container)
Should I append it to the Laravel? (because it's the main)
Thank you
To connect redis to Laravel see laravel official document
To connect lumen to redis see this links:
lumen doc for cache
lumen doc for queue
You can put your redis in any server you want and connect it to laravel or lumen with (in your .env file):
REDIS_Host="yout server"
REDIS_port="port of your server to connect redis"
REDIS_password="password which set in redis"
NOte: You are not force append redis to laravel if you need it in lumen just!
First of all, Redis is an in-memory data structure that is used as a database, cache and message broker What is Redis. It is similar to the database (DB) you would connect to but not something you can include in your app.
It sits somewhere, running as a daemon and you connect to it for the purposes of caching or message brokering, etc.
Now that you know you cannot append to it, do you want faster caching or session management? do you have the resources to support it? If yes, then you should connect to Redis.
Kindly take notice of something however, if you are going to run both Lumen and Laravel on the same system, you have to make certain changes to both environment files for the two applications.
eg. .env (Laravel app), you can change things like REDIS_HOST to REDIS_HOST_LARAVEL while you maintain it for .env (Lumen app). Another example is DB_HOST to something else like MY_DB_HOST and change them accordingly in the config/ files.
For some reason they can behave weird running to Lumen or Laravel apps on the same server connecting to Redis for cache or session management.
I have a Laravel application deployed on AWS Elastic Beanstalk with a classic load balancer. Somehow the user sessions expire at irregular times. Sometimes it expires right after logging in and most times few minutes after logging in. On some occasions to, it takes hours to expire. but on localhost, this doesn't happen.
I have configured my session duration in my Laravel application to 10hours and this works perfectly on localhost but somehow it doesn't work on AWS ELB.
I'm suspecting that AWS resets the app sessions a number of times within a day. If that's the case, how do I overcome this? If that's not the case, then what might be causing this?
I'm posting the answer here just so anyone runs into the same problem. What happens with AWS servers is that, They kind of redeploy your codes a couple of times a day and this clears all newly created files and uploaded files in your project. That's why you have to use a cloud storage if you want to store files and the same thing happens with sessions.
By default laravel saves sessions in a file and whenever AWS redeploy your code, it wipes all current session because it deletes the session file. The solution is store the sessions anywhere but the file. So i used my database to store sessions and cache. You can do that by
Going to the config/session.php and changing the driver to database
After run
php artisan session:table
php artisan migrate
These will create the sessions table in the database for you and that should fix the AWS problem. Just like #arun-a said in short. you can checkout the sessions docs for more info.
If you are using load balancer, you have to keep session as centralized to access over multiple servers. So use session driver as database instead of file and do related migration. Refer here.