I am posing order-data on ssl means (https) based api via curl, But it return OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104 message.
Here is my test code as per client required 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" => "[email protected]",
"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);
How to find reason for the failure? What could be the reason for failure? kindly provide your suggestions.
There are probably many reasons you might get this.
For me, I got this because I was using curl and the web site I was accessing didn't like curl being used. I fixed this with:
curl -A "Mozilla Chrome Safari" someserver.com/somepage.html
This tells curl to say to the server, 'hey I'm a browser'. You can use your favourite browser to get a nicer newer string, go to the browser developer console typically under 'network' you can see individual request items and there you can get the string your current browser sends as the 'user-agent'.
The reason why a website would do this is your typical customer doesn't use curl. Best case a curl will be a bot using up server resource, worst case it's an evil hacker.
I had same issue.
OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104
I guessed the error was regarded openssl or etc. But, it was not.
In my case, one of POST parameters was wrong value. (something like OTP code) And I resolved it finally.
In the standard C library the variable errno
contains the code for what went wrong with the most recent system call. The value of 104 is defined as ECONNRESET
which means "Connection reset by peer".
The error simply means the other side hung up on you, without completing the normal HTTPS protocol and giving back anything in return ... possibly for all sorts of reasons, could be network problems, or server-side program crash, or the other end simply does not like what you did. It's not really related to OpenSSL at all, and to know what caused it you would need access to the server logs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With