http request between 2 local apps: deadlock with default settings!
-
Hi,
I am new to Laragon and had some troubles with my setup that took me hours yesterday. Maybe my (simple) solution helps others, or or better maybe the default settings could be changed by the Laragon team to prevent this.
Setup:
2 Local (Laravel) Apps talking to each other over Http REST APIs.
Browser -> makes a Http-Request to App 1 -> within the request App 1 makes a Guzzle-Http Request to the API of App 2This results in a permanent deadlock!
Reason:
Nginx has in the default config only one PHP upstream slot, so App 1 is waiting for the result of the API Reqeust, this is scheduled by Nginx until the first Http Request is closed. A classic deadlock situationSolution:
In your usr/laragon.ini: Add
[nginx]
Upstream=2 (or a higher value)I am not sure why this happens (is upstream a nginx setting or is there some magic done by laragon inbetween?
Anyway @laragonTeam please add Upstream > 1 as default value for futures releases.
-
@peterreb : Many thanks for posting your issue and solution here. The upstream magic is done by Laragon and I will set it > 1 as your request.
-
What about apache? Does this issue affects it as well?
-
@peterreb : I've release Laragon 4.0.14 which set the Upstream=2 by default.
https://forum.laragon.org/topic/1204/laragon-4-0-released-with-quick-add-feature@gsabater : This issue does not affect Apache. However, please be careful when using env vars in Apache in Laravel when you have 2+ apps which communicate each other:
https://forum.laragon.org/topic/1468/why-you-should-use-nginx-instead-of-apache-for-laragon
-
@leokhoa I'm using Apache and not always but sometimes (usually on heavy requests) my app tries to connect to the database via other app's .env values and they do not even communicate each other, just separate projects.
-
@mgsmus said in http request between 2 local apps: deadlock with default settings!:
@leokhoa I'm using Apache and not always but sometimes (usually on heavy requests) my app tries to connect to the database via other app's .env values and they do not even communicate each other, just separate projects.
I have exactly this same issue. I usually solve this by refreshing view cache, composer cache and any other sessions
-
@gsabater .env file cached by config:cache. I don't use config:cache at all. It clearly reads another project's .env file (I can see the wrong database name on network tab while doing ajax requests) but cannot figure out how can it be possible.
-
I've had the same issues and found a solution described here:
https://forum.laragon.org/topic/1468/why-you-should-use-nginx-instead-of-apache-for-laragon/2