0

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.

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
  • did you check if the server isn't undergoing any maintenance? http://status.ovh.com/ – Mederic May 30 '17 at 08:31
  • Yes, I call Ovh and they told me there is no probleme with the server, and as I say, I call the Api on my controller and it's actually working.. the problem really come from the command :( – Gianni Fuina May 30 '17 at 08:40
  • in ssh, try to ping to the target server. there could be a firewall issue. Your firewall or ovh. – sadlyblue May 30 '17 at 08:58
  • Indeed, I can't ping the Ovh Api Ip : `ping 213.186.33.117` and get `connect: Network is unreachable`. How can I solve that ? – Gianni Fuina May 30 '17 at 09:02

2 Answers2

0

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.

L01C
  • 578
  • 1
  • 8
  • 25
  • Thanks ! I will try this. Just a question, did you put your "myfile.sh" in the www folder ? – Gianni Fuina May 30 '17 at 09:27
  • Yes I did. In the .sh file your path have to be "/home/yourname/www/yourpath....". You can find it by doing a php realpath. In the ovh cron menu, your path have to be "www/....". Choose "other langage", and don't forget to check "activate it". – L01C May 30 '17 at 09:30
  • I have a probleme understandig the placement of the files. Currently, I have a tree like that : **/home/myNameSite/www**. Where I'm supposed to put the myfile.sh ? And what about thtat ? : `cd /home/MyNameSite /usr/local/php5.6/bin/php bin/console converseo:updateTelephony` – Gianni Fuina May 30 '17 at 12:20
  • Place it wherever you want. – L01C May 30 '17 at 12:22
  • Okay, suppose thtat I put in on /home/myNameSite/www/myfile.sh. Does `cd /home/MyNameSite` work ? And on the Ovh menu, what is the path after **./** ? – Gianni Fuina May 30 '17 at 12:27
  • No. You have to put the complete path. So for you : cd /home/MyNameSite/www . On ovh : www/yourfile – L01C May 30 '17 at 12:29
  • Okay I put that ! I tell you in one hour (I can't reduce the execution time in ovh...) the result :) Thanks ! – Gianni Fuina May 30 '17 at 12:34
  • Yes I know this "1 hour" thing ^^ . A little tip: a cron task is one per hour,but you can create 20 same cron tasks. It will run at a random minute(the number before ****, for example 5**** means each hour at 01h05, 02h05 etc). So you can launch your cron task each minute if you want, for testing ;). Hopefully it will work! – L01C May 30 '17 at 13:31
  • Unfortunately, I get this error : `[2017-05-30 14:43:02] ## OVH ## START - 2017-05-30 14:43:02.253272 executing: /homez.93/MyNameSite/./www/test.sh [2017-05-30 14:43:02] No such file or directory` I don't know where is my path problem – Gianni Fuina May 30 '17 at 13:45
  • I don't know why there is a **./** before **/www**, I thought that Ovh didn't take it.. – Gianni Fuina May 30 '17 at 14:13
  • It's not the problem. In my case I 've got : "## OVH ## START - 2017-05-30 16:06:03.295628 executing: /homez.myNumber/mysite/./www/folder/folder/cronall.sh " . And it works. – L01C May 30 '17 at 14:19
  • Are you sure your test.sh is on the folder www ? – L01C May 30 '17 at 14:27
  • Yes, my file is in **home/MySiteName/www/test.sh**, it contains **/usr/local/php5.6/bin/php bin/console converseo:updateTelephony** and in ovh, I put the path to **./www/test.sh** – Gianni Fuina May 30 '17 at 14:46
  • And un get : `[2017-05-30 16:43:02] ## OVH ## START - 2017-05-30 16:43:02.115860 executing: /homez.93/converseca/./www/test.sh [2017-05-30 16:43:02] Exec format error [2017-05-30 16:43:02] [2017-05-30 16:43:02] ## OVH ## END - 2017-05-30 16:43:02.259420 exitcode: 255` – Gianni Fuina May 30 '17 at 14:49
  • Your file have to contain #!/bin/bash on the first line. Try some different test to find the good ovh cron path. You can try with php file too (not necessarly the .sh). – L01C May 30 '17 at 14:50
  • Okay ! I think the path is good (cause of **Exec format error**) so I'll see with **#!/bin/bash** Thanks :) – Gianni Fuina May 30 '17 at 14:52
  • Ok nice, this time it seems your cron task found your file. Should works. – L01C May 30 '17 at 14:53
  • Still not working.. it seems that the code is launching but get error : `[2017-05-30 17:07:01] ## OVH ## START - 2017-05-30 17:07:01.372266 executing: /homez.93/MyNameSite/www/test.sh [2017-05-30 17:07:01] No such file or directory [2017-05-30 17:07:01] [2017-05-30 17:07:01] ## OVH ## END - 2017-05-30 17:07:01.455275 exitcode: 255` – Gianni Fuina May 30 '17 at 15:13
  • Show me your sh file. – L01C May 31 '17 at 07:29
  • My sh files : `#!/bin/bash /usr/local/php5.6/bin/php bin/console converseo:updateTelephony` My path is good cause I try with a Php files and my echo works fine – Gianni Fuina May 31 '17 at 07:53
  • Did you manage it in 3 different lines like in my example ? Don't write everything in the same line. Are you sure you use the good version of php ? Are you sure php is accessible with this path for you ? Maybe you should ask on OVH forum, or OVH support team. I can't help you more. If you think my suggestion helped you, don't hesitate to vote ;) . Good luck! – L01C May 31 '17 at 08:38
0

I resolved my problem by putting a PHP file into my www folder, which contains :

<?php
    shell_exec("sh myfile.sh");
?>

And myfile.sh :

#!/bin/bash
cd /homez.myNumber/MyNameSite/www
/usr/local/php5.6/bin/php bin/console converseo:MyCommand --env=prod
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42