[英]Curl Error : Failed to connect to <url> port 8444: Connection refused, works in local but not in server
I am trying to integrate bank online payment system. 我正在尝试整合银行在线支付系统。 For that I need to make handshake with bank server.With crt and key file i have done it in localhost with curl,sending crt and key file to band server while performing handshake and they approved it.But somehow when I upload the project in server it give error "Curl Error : Failed to connect to port : Connection refused" , i want to know what might cause this problem, do i need to store crt and key file in specific folder?
为此,我需要与银行服务器进行握手。使用crt和密钥文件,我已经在localhost中使用curl进行了此操作,在进行握手时将crt和密钥文件发送到band服务器,他们批准了它。它给出错误“卷曲错误:无法连接到端口:连接被拒绝”,我想知道是什么原因导致此问题,我是否需要将crt和密钥文件存储在特定的文件夹中? the website is ssl certified.
该网站已通过ssl认证。 my curl code is:
我的卷曲代码是:
$request = <has xml file>
$twpg_gateway_url = <url>;
$twpg_cert_file = getcwd().'\wp-content\themes\nikkon\website.com.crt';
//echo getcwd();exit();
$twpg_key_file = getcwd().'\wp-content\themes\nikkon\website.key';
$twpg_key_password = <password>;
$curl = curl_init();
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POST => true,
CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
CURLOPT_VERBOSE => true,
CURLOPT_URL => $twpg_gateway_url . '/Exec',
CURLOPT_POSTFIELDS => $request,
CURLOPT_HTTPHEADER => array('Content-Type: text/xml'),
CURLOPT_TIMEOUT => 30
);
if ($twpg_cert_file != '') {
$options[CURLOPT_SSLCERT] = $twpg_cert_file;
$options[CURLOPT_SSLKEY] = $twpg_key_file;
$options[CURLOPT_SSLKEYPASSWD] = $twpg_key_password;
}
curl_setopt_array($curl, $options);
$response = curl_exec($curl);
if(!$response)
{
echo "Curl Error : " . curl_error($curl);
}
curl_close($curl);
return $response;
This is a script I use to test if a port is open. 这是我用来测试端口是否打开的脚本。
try {
$hostname = isset($_SERVER['argv'][1])? $_SERVER['argv'][1]: 'localhost';
$port = isset($_SERVER['argv'][2])? $_SERVER['argv'][2]: 80;
printf(' ? Attempting to connect to: %s:%u', $hostname, $port);
if(@fsockopen($hostname, $port, $code, $message, 5) === false) {
throw new RuntimeException($message, $code);
}
printf("\r:) Successfully connected to: %s:%u", $hostname, $port);
}
catch(Exception $e) {
printf("\nError: %u - %s", $e->getCode(), $e->getMessage());
exit(1);
}
Run it like this from the command line php socket-test.php example.com 25
. 从命令行
php socket-test.php example.com 25
像这样运行它。 Or you could modify it to work in a web browser. 或者,您可以对其进行修改以在Web浏览器中工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.