-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Connection refused Handling #2707
-
I am currently working on a project using Laravel 8 with jenssegers version 3.8. The project involves the use of both MySQL and MongoDB databases, with approximately 90% of the modules relying on MySQL and the remaining 10% on MongoDB. The issue I'm facing is that when the MongoDB server is down, it results in the entire application being inaccessible. I am seeking guidance on how to handle this situation. Ideally, I would like the application to gracefully continue functioning by utilizing the MySQL modules when the MongoDB server is unavailable. Any assistance or advice on implementing a robust solution to handle this scenario would be greatly appreciated. Thank you for your time and support.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 3 replies
-
Hell @stevedivinep, the MongoDB\Client
doesn't initiate the communication with the server before the first command. There may be some code in you application or in this library that runs a command on every application request.
Can you give the exception with the full backtrace, and maybe check the code that causes this error? You can test by setting an incorrect url in your configuration.
Beta Was this translation helpful? Give feedback.
All reactions
-
you are correct @GromNaN ,Library that runs a command on every application request. I need to handle this. But i don't know how to handle this situation.
Beta Was this translation helpful? Give feedback.
All reactions
-
If you own the code that does the command, wrap it in a try-catch if it's only to continue the execution in case of error.
I don't have enough information to help you otherwise.
Beta Was this translation helpful? Give feedback.
All reactions
-
I have already performed these actions. Nevertheless, the server error page persists. I have attempted changes in both the vendor page and Exception/Handler.php. In the vendor file, the error does not occur within the catch block. In the Handler file, the exception is thrown, but I am uncertain about how to redirect to another page or handle it differently
Beta Was this translation helpful? Give feedback.