diff --git a/ApnsPHP/Push.php b/ApnsPHP/Push.php index 225fd53e..ed9045db 100644 --- a/ApnsPHP/Push.php +++ b/ApnsPHP/Push.php @@ -638,6 +638,15 @@ private function httpSend(Message $message, &$reply): bool CURLOPT_POSTFIELDS => $message->getPayload() ]) && ($reply = curl_exec($this->hSocket)) !== false) ) { + $errorCode = curl_errno($this->hSocket); + + if ($errorCode > 0) { + $this->logger->error('HTTP request error code: {code}; message: {message}.', [ + 'code' => $errorCode, + 'message' => curl_error($this->hSocket), + ]); + } + return false; } diff --git a/ApnsPHP/Tests/PushHttpSendTest.php b/ApnsPHP/Tests/PushHttpSendTest.php index e5b00304..eecb6c9d 100644 --- a/ApnsPHP/Tests/PushHttpSendTest.php +++ b/ApnsPHP/Tests/PushHttpSendTest.php @@ -99,6 +99,14 @@ public function testHttpSendReturnsFalseOnCurlOptsCannotBeSet(): void return true; }); + $this->mock_function('curl_errno', function () { + return 56; + }); + + $this->mock_function('curl_error', function () { + return 'OpenSSL SSL_read: error:14094415:SSL routines:ssl3_read_bytes:sslv3 alert certificate expired'; + }); + $this->set_reflection_property_value('environment', 1); $this->setHttpHeaders(); diff --git a/ApnsPHP/Tests/PushSendTest.php b/ApnsPHP/Tests/PushSendTest.php index c7f0368f..99ecd1f0 100644 --- a/ApnsPHP/Tests/PushSendTest.php +++ b/ApnsPHP/Tests/PushSendTest.php @@ -69,6 +69,12 @@ public function testSendFailsWithoutRetrying(): void $this->mock_function('curl_init', function () { return new stdClass(); }); + $this->mock_function('curl_errno', function () { + return 0; + }); + $this->mock_function('curl_error', function () { + return ''; + }); $error = [ 'command' => 8, @@ -206,6 +212,12 @@ public function testSendRemovesWhenNoError(): void $this->mock_function('curl_close', function () { return null; }); + $this->mock_function('curl_errno', function () { + return 0; + }); + $this->mock_function('curl_error', function () { + return ''; + }); $this->mock_function('curl_init', function () { return new stdClass(); });