[英]PHP Curl+connection refused
我的 PHP Curl 出现此错误
* Hostname in DNS cache was stale, zapped
* Trying xxx.xx.x.xx...
* connect to xxx.xx.x.xx port 4005 failed: Connection refused
* Failed to connect to sample.website.net.au port 4005: Connection refused
* Closing connection 0
我有这个代码:
$ch = curl_init();
$headers = array(
'Content-type: text/xml',
'charset: utf-8',
'SOAPAction: urn:ServiceQualification#AddresSsearch',
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$verbose = fopen('php://temp', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); // This should always be set to 'TRUE' when in production to ensure the SSL is enabled.
$response = curl_exec ($ch);
if ($result === FALSE) {
printf("cUrl error (#%d): %s<br>\n", curl_errno($ch),
htmlspecialchars(curl_error($ch)));
}
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
echo "Verbose information:\n<pre>", htmlspecialchars($verboseLog), "</pre>\n";
curl_close ($ch);
return $response;
我不知道为什么我会遇到这个错误。 我在我的本地主机上尝试了这个,它运行良好,但是当我将它上传到我的服务器时,我收到了上述 php curl 错误。
这里似乎有什么问题? 我需要联系我尝试连接的网址吗?
我现在正在敲我的头,您的帮助将不胜感激。
谢谢!
拒绝连接:
检查您是否可以将外发连接到端口 4005。可能是您的防火墙阻止了您。
检查您是否可以将外发连接到端口 4005。可能是远程防火墙阻止了您。
检查是否可以通过终端 ping 远程主机:
ping 1.2.3.4 // this is the ip, you can also use the hostname.
尝试通过终端将远程主机与特定端口连接:
telnet 1.2.3.4 4005
这比通过 php 代码调试更容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.