PHP CURL Error - curl: (56) Recv failure: Connection reset by peer

后端 未结 3 1048

basically, this error only occurs in CURL

curl: (56) Recv failure: Connection reset by peer

But when I visit it directly the link directly

相关标签:
3条回答
  • 2020-12-17 19:36

    I had similar problem with this code:

            $url = "http://xxx.xxx.xxx.xxx";
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_PORT, 44455); //Set the port to connect to
            //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 44455); 
            curl_setopt($ch, CURLOPT_URL, $url);
            echo $xml = curl_exec($ch);
            if(curl_errno($ch))
            {
                echo 'error:' . curl_error($ch);
            }
            curl_close($ch);
    

    Got it solved by disabling this:

            //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 44455);
    
    0 讨论(0)
  • 2020-12-17 19:38

    I remember facing the same issue a long time back. While I don't remember what exactly sorted out the issue, I remember trying the following:

    1. I was trying to pass the query parameters in the URL directly and I tried passing through POST method

    2. I tried using a proxy with curl to see if I was possibly being blocked by the other server

    3. I believe I also asked my host to look into it and they made some Apache setting changes

    0 讨论(0)
  • 2020-12-17 19:51

    I resolved this issue by removing whitespace characters from the URL. In my situation, it was the proxy server that was erroring out, not the web server.

    In PHP:

         curl_setopt($ch, CURLOPT_URL, trim($url));
    
    0 讨论(0)
提交回复
热议问题