I’m working on a Laravel 11 project with PHP 8.3, hosted on an OVH Pro shared server. The project involves making API calls to write data to a blockchain. This API call is scheduled to run once a day using Laravel’s scheduler, which is managed by a cron job on the OVH server.
The API call must occur at a fixed time but not necessarily through the scheduler. The issue I’m encountering is that OVH blocks the use of cURL on their shared servers. I currently use the Laravel IlluminateSupportFacadesHttp
facade for HTTP requests. However, when I try to execute the command, I get the following error:
In PendingRequest.php line 939:
cURL error 7: Failed to connect to stagingblockchain.izzymobility.com port 443: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://stagingblockchain.izzymobility.com/api/auth/login
Notably, the API call works fine within the project itself.
I contacted OVH, and they told me they block most cURL requests.
Solutions I’ve Tried:
- Modifying the API Call Method:
- Using Guzzle directly instead of Laravel’s HTTP facade (which is based on Guzzle), and switching the handler to stream instead of cURL.
- Investigating the socket handler but couldn’t find enough information to implement it.
- Using plain PHP
- Using Guzzle directly instead of Laravel’s HTTP facade (which is based on Guzzle), and switching the handler to stream instead of cURL.
- Modifying How the Scheduler Executes the Call:
- Using a job instead of a command.
- Creating a controller with a GET route to execute the call.
- The call works when I visit the URL directly but not when the scheduler executes it.
- Instantiating the controller, since OVH blocks even cURL to the server’s address.
- Attempting to access the route from a JavaScript file using fetch.
Despite these efforts, I’m out of potential solutions and considering switching servers. Does anyone have any ideas or suggestions for other approaches I could try to resolve this issue?
Thank you!
Equipe dev is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.