PHP curl fails to connect to intranet server

Asked 2 years ago, Updated 2 years ago, 101 views

I have been using the packaged version of Cybows Galoon SOAPAPI without any problems.
Something has prevented me from getting it with the API.

The symptom is that communication using curl cannot reach the intranet server.

If you use aaaaa in the code below as the hostname, a DNS error page will be returned and
The IP address also times out.
I also use the cloud version, so if I change the URL itself to cloud, xml will be returned successfully.
(If the URL is https://www.google.com/, HTML returns, but if it is an intra-server URL, DNS error)

If you use file_get_contents, both packaged and cloud versions will return xml without any problems.

The server was installed in the same segment as the garoon in Windows 2012 and
No winhttp proxy (IE option proxy is set)

I set the same version of PHP on another Windows 2012 server and tried the same code, but there was no problem.
Is there only a reinstallation of the server?

 echo curl_get_contents("http://aaaaa/scripts/cbgrn/grn.exe?WSDL",",",$timeout=60);    
 // echo file_get_contents("http://aaaaa/scripts/cbgrn/grn.exe?WSDL");
 exit;
    
 function curl_get_contents($url,$request,$timeout=60){
        $ch = curl_init();
        $header=array('Content-Type:application/soap+xml; charset=UTF-8;');
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch,CURLOPT_TIMEOUT,$timeout);
        curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
        $result=curl_exec($ch);
        curl_close($ch);
        return$result;
 }

php php-curl

2022-09-30 14:39

1 Answers

Self-resolved!

It looks like you need to explicitly set the proxy empty for the intra side…

 curl_setopt($ch,CURLOPT_PROXY,'');

More difficult to understand is that once you run this process, it seems to be remembered.
From now on, I will be able to use this server without the above sentence (' '')…


2022-09-30 14:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.