louisjeck's avatar

Laravel app not responsive to other requests while making Guzzle request

Hello, I'm trying to generate PDFs using Browserless PDF Api from views from my Laravel App. Right now my app is using Sail, and Browserless is running in Docker, sharing a Network so they can communicate. I have a simple route that makes a GuzzleHttp request to my Browserless instance, using the /pdf endpoint. If i provide an external URL like https://google.com, I successfully get a PDF after a few seconds. But as soon as I provide an URL pointing to my app, the action times out. Using Postman to make the same request does generate a PDF from my app, so Browserless can communicate with the Sail server. But I've noticed that the whole app becomes unresponsive while making a GuzzleHttp request, and that why I get a timeout when the app calls Browerless with an URL from itself. Any thoughts on why making a request using GuzzleHttp would block the whole website ?

Thank you

0 likes
8 replies
Snapey's avatar
Snapey
Best Answer
Level 122

@louisjeck Sail uses artisan serve as its webserver. This is single-threaded and therefore you cannot place a request on the site from a request on the same site.

3 likes
bugsysha's avatar

Yap, blocking IO. Another request can't be processed until the current is not finished.

1 like
louisjeck's avatar

@bugsysha Ah thanks, I figured it was something like that. I've gotten around it using a Job and it works, just complicates it a bit !

bugsysha's avatar

@louisjeck change your development process. It is not going to be like that in production. You will have a proper web server. Don't complicate things more than you have to.

valentin_vranic's avatar

@snapey Could you please provide some solutions? I'm facing the same issue, calling internal API endpoint with guzzle, in Laravel Sail

krisi_gjika's avatar

@valentin_vranic "calling internal API endpoint" - first of all why?

"Could you please provide some solutions?" - develop with a real webserver if you need to perform multiple requests on the same site at the same time

1 like

Please or to participate in this conversation.