php - OpenSSL SSL_read : SSL_ERROR_SYSCALL, 错误号 104

标签 php curl

我通过 curl 在基于 ssl 方法 (https) 的 api 上提交订单数据,但它返回 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 消息。

根据客户要求的 json,这是我的测试代码:

$apiKey = "xxxxxx-xxxxxx-xxxxx-xxxxxx-xxxxxx";
$privatekey = "xxxxxx-xxxxxx-xxxxx-xxxxxx-xxxxxx";
$timestamp = date('Y-m-d H:i:s'); // (for example: 2016-07-19 14:05:55)

$signature = hash_hmac('sha1', $timestamp, $apiKey);
$signature = hash_hmac('sha1', $privatekey, $signature);

$postURL = "https://www.compu-cover.com/intelligent-rewards/orders/?OrderNo=123";

$orderInfo['Order'] = array(
        "apiKey" => $apiKey,
        "privatekey" => $privatekey,
        "Signature" => $signature,
        "Timestamp" => $timestamp,
        "Firstname" => "Ajay",
        "Surname" => "Sharma",
        "EmailAddress" => "ajay@yopmail.com",
        "DaytimeTel" => "0141798526",
        "EveningTel" => "0141798526",
        "MobileTel" => "9887654321",
        "Address1" => "A-5",
        "Address2" => "Jhalana",
        "Address3" => "Jaipur",
        "Address4" => "Rajasthan",
        "County" => "India",
        "Postcode" => "302019", 
        "Cover" => "ADTBL",
        "Scheme" => 2, 
        "Premium" => 5,
        "EquipmentQty" => 1,
        "EquipmentType1" => "Smartphone",
        "EquipmentMake1" => "Moto",
        "EquipmentModel1" => "Moto G",
        "EquipmentPrice1" => 100
    );

$params = json_encode($orderInfo);

$session = curl_init($postURL);

curl_setopt($session, CURLOPT_POST, true);
curl_setopt($session, CURLOPT_POSTFIELDS, $params);
curl_setopt($session, CURLOPT_HEADER, true);
curl_setopt($session, CURLOPT_SSL_VERIFYPEER, true); 

$response = curl_exec($session);

if (FALSE === $response) {
    var_dump(curl_error($session));
    var_dump(curl_errno($session));
}

curl_close($session);
$response = json_decode($response);

var_dump($response);

如何查找失败的原因?失败的原因可能是什么?请提供您的建议。

最佳答案

在标准 C 库中,变量 errno 包含最近系统调用出错的代码。 104 的值定义为 ECONNRESET,表示“连接由对等方重置”。

错误只是意味着对方挂断了你,没有完成正常的 HTTPS 协议(protocol)并返回任何返回......可能出于各种原因,可能是网络问题,或者服务器端程序崩溃,或者另一端根本不喜欢你所做的。它与 OpenSSL 根本没有关系,要知道是什么导致了它,您需要访问服务器日志。

关于php - OpenSSL SSL_read : SSL_ERROR_SYSCALL, 错误号 104,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46195374/

相关文章:

php减去关联数组

Java 套接字只接受 header

json - Golang json.decoder 无法仅解码来自浏览器的请求

php - 从 'table' 删除,其中 id ='selected record ' ?

php - 如何以最有效的方式使用通配符?

php - MySQL 十进制 9.99999999

bash - 如何通过 curl 请求来暴力破解不安全的登录

php 中的 cURL 选项 - 什么选项是 -u

正则表达式问题通过 curl 向 Varnish 服务器发送 BAN 请求

php - Laravel hasMany 具有基于附加关系的条件