Php Curl Connectin timed out

I have worpdress plugin which communicate with my production site https://mysite.com via curl.
Here is the curl code:

   $vars = json_encoded(
                array(
                   //some params
                  );
   );

    $headers = array(
        'Accept: application/json',
        'Content-Type: application/json',
    );

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://mysite.com/myapi");
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $result = curl_exec($ch);

    var_dump(curl_error($ch);

It works fine for all wp sites which use my plugin, but suddenly it stop working for just one site:
and curl_error() returns this:

Read More
Failed to connect to mysite.com port 443: Connection timed out

Also my plugin is not on the wordpress repository, it’s placed on https://mysite.com/plugin and my plugin use hook “site_transient_update_plugins” to check for available update. This also doesn’t work anymore and they don’t get message about update available anymore.

So I guess that they changed something on their server which cause this problem, and I just cannot find what can cause this.

Also I am not 100% sure, but connection take about 300 s before it throw this error. And 300 s is default value for CURLOPT_CONNECTTIMEOUT.

So any suggestion what can cause this behavior will help.

Related posts

Leave a Reply

2 comments

  1. try to telnet your site to ensure the port 443 open and accessible

    telnet mysite.com 443
    

    if you got response then mean there are not issue with your firewall and Apache /web server.

    that is not only issue with firewall you should also check with your web-server that there are 443 port open or not.