Search code examples
phpapisymfonyovh

Impossible to access OVH API from Symfony command online


Here is my problem: I'm developing a Symfony project which accesses telephony and email data from OVH API. Since I'm working in local, I've never met any problems, the API connection was working and I could recover all data.

Yesterday I deployed my project online on an OVH hosting, and when I launch a command from the SSH panel, I get cURL error 7.

The problem doesn't come from the API because I call it in my Controller and I don't get any errors.

My command is :

(php/5.6/production/) ~/www $ php bin/console converseo:updateTelephony

And the error I get :

[GuzzleHttp\Exception\ConnectException]
  cURL error 7: Failed to connect to 213.186.33.117: Network is unreachable (
  see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

I don't know why this command works on localhost and in my controller, but doesn't work online.


Solution

  • I've got a similar problem in the past with SSH.

    I resolved it by creating a CRON task in OVH admin menu. This CRON task call myfile.sh.

    Myfile.sh:

    #!/bin/bash
    cd /home/yourpath
    /usr/local/php5.6/bin/php bin/console converseo:updateTelephony
    

    It was ok for me because I needed to execute the command only sometimes in the day. I hope it will helps you.

    If you need to launch this command in a specific moment, I think you will need to upgrade your hosting account(vps for example) and type the command directly on the server.