fwrite(): SSL operation failed with code OpenSSL Error messages:nerror:1409F07F:SSL routines:SSL3_WRITE_PENDING










0















I have got some problem and tried all suggestion but no help. I am not getting what is the error.
Everything is to be going perfect but when call fwrite() then it will give error and stop further execution.



If anyone has an idea about it, please share with us. Thanks.



Here is my function that i am using for send push notification to iOS using PHP laravel:



function send_custom_IOSNotification($registatoin_ids, $finalArrayVal, $title, $env = false) 
$passphrase = '1234';
$ctx = stream_context_create();
$path = storage_path();
if($env)
stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/apns-dev-cert.pem');
else
stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/pushcert.pem');


stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
stream_context_set_option($ctx, 'ssl', 'cafile', $path.'/entrust_2048_ca.cer');

if($env)
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT else STREAM_CLIENT_PERSISTENT, $ctx);


if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);

$arrlength=count($registatoin_ids);

Log::useFiles(storage_path().'/logs/notification.log');

for($x=0;$x<$arrlength;$x++)

$finalArrayVal['aps'] = array(
'alert' => $title,
'badge' => $registatoin_ids[$x]['badge'],
'sound' => 'default'
);

foreach($finalArrayVal as $key => $value)
$finalArrayVal[$key] = array_map('strval', $finalArrayVal[$key]);


updateUserBadges($registatoin_ids[$x]['user_id'],$registatoin_ids[$x]['badge']);
$payload = json_encode($finalArrayVal);
$msg = chr(0) . pack('n', 32) . pack('H*', $registatoin_ids[$x]['device_id']) . pack('n', strlen($payload)) . $payload;

$result = fwrite($fp, $msg, strlen($msg));

if (!$result)
Log::info('Message not delivered at '.$x);
fclose($fp);
if($env) STREAM_CLIENT_PERSISTENT, $ctx);
else
$fp = stream_socket_client('tls://gateway.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT
else
Log::info('Message successfully delivered at '.$x);


fclose($fp)









share|improve this question






















  • What version of PHP is it? According to github.com/reactphp/stream/issues/64 there was a bug in PHP that produced this same error that was fixed in in PHP 7.1.4 and 7.0.18. See here for a workaround: stackoverflow.com/questions/14695247/…

    – Mike
    Nov 16 '18 at 3:49
















0















I have got some problem and tried all suggestion but no help. I am not getting what is the error.
Everything is to be going perfect but when call fwrite() then it will give error and stop further execution.



If anyone has an idea about it, please share with us. Thanks.



Here is my function that i am using for send push notification to iOS using PHP laravel:



function send_custom_IOSNotification($registatoin_ids, $finalArrayVal, $title, $env = false) 
$passphrase = '1234';
$ctx = stream_context_create();
$path = storage_path();
if($env)
stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/apns-dev-cert.pem');
else
stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/pushcert.pem');


stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
stream_context_set_option($ctx, 'ssl', 'cafile', $path.'/entrust_2048_ca.cer');

if($env)
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT else STREAM_CLIENT_PERSISTENT, $ctx);


if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);

$arrlength=count($registatoin_ids);

Log::useFiles(storage_path().'/logs/notification.log');

for($x=0;$x<$arrlength;$x++)

$finalArrayVal['aps'] = array(
'alert' => $title,
'badge' => $registatoin_ids[$x]['badge'],
'sound' => 'default'
);

foreach($finalArrayVal as $key => $value)
$finalArrayVal[$key] = array_map('strval', $finalArrayVal[$key]);


updateUserBadges($registatoin_ids[$x]['user_id'],$registatoin_ids[$x]['badge']);
$payload = json_encode($finalArrayVal);
$msg = chr(0) . pack('n', 32) . pack('H*', $registatoin_ids[$x]['device_id']) . pack('n', strlen($payload)) . $payload;

$result = fwrite($fp, $msg, strlen($msg));

if (!$result)
Log::info('Message not delivered at '.$x);
fclose($fp);
if($env) STREAM_CLIENT_PERSISTENT, $ctx);
else
$fp = stream_socket_client('tls://gateway.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT
else
Log::info('Message successfully delivered at '.$x);


fclose($fp)









share|improve this question






















  • What version of PHP is it? According to github.com/reactphp/stream/issues/64 there was a bug in PHP that produced this same error that was fixed in in PHP 7.1.4 and 7.0.18. See here for a workaround: stackoverflow.com/questions/14695247/…

    – Mike
    Nov 16 '18 at 3:49














0












0








0








I have got some problem and tried all suggestion but no help. I am not getting what is the error.
Everything is to be going perfect but when call fwrite() then it will give error and stop further execution.



If anyone has an idea about it, please share with us. Thanks.



Here is my function that i am using for send push notification to iOS using PHP laravel:



function send_custom_IOSNotification($registatoin_ids, $finalArrayVal, $title, $env = false) 
$passphrase = '1234';
$ctx = stream_context_create();
$path = storage_path();
if($env)
stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/apns-dev-cert.pem');
else
stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/pushcert.pem');


stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
stream_context_set_option($ctx, 'ssl', 'cafile', $path.'/entrust_2048_ca.cer');

if($env)
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT else STREAM_CLIENT_PERSISTENT, $ctx);


if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);

$arrlength=count($registatoin_ids);

Log::useFiles(storage_path().'/logs/notification.log');

for($x=0;$x<$arrlength;$x++)

$finalArrayVal['aps'] = array(
'alert' => $title,
'badge' => $registatoin_ids[$x]['badge'],
'sound' => 'default'
);

foreach($finalArrayVal as $key => $value)
$finalArrayVal[$key] = array_map('strval', $finalArrayVal[$key]);


updateUserBadges($registatoin_ids[$x]['user_id'],$registatoin_ids[$x]['badge']);
$payload = json_encode($finalArrayVal);
$msg = chr(0) . pack('n', 32) . pack('H*', $registatoin_ids[$x]['device_id']) . pack('n', strlen($payload)) . $payload;

$result = fwrite($fp, $msg, strlen($msg));

if (!$result)
Log::info('Message not delivered at '.$x);
fclose($fp);
if($env) STREAM_CLIENT_PERSISTENT, $ctx);
else
$fp = stream_socket_client('tls://gateway.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT
else
Log::info('Message successfully delivered at '.$x);


fclose($fp)









share|improve this question














I have got some problem and tried all suggestion but no help. I am not getting what is the error.
Everything is to be going perfect but when call fwrite() then it will give error and stop further execution.



If anyone has an idea about it, please share with us. Thanks.



Here is my function that i am using for send push notification to iOS using PHP laravel:



function send_custom_IOSNotification($registatoin_ids, $finalArrayVal, $title, $env = false) 
$passphrase = '1234';
$ctx = stream_context_create();
$path = storage_path();
if($env)
stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/apns-dev-cert.pem');
else
stream_context_set_option($ctx, 'ssl', 'local_cert', $path.'/pushcert.pem');


stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
stream_context_set_option($ctx, 'ssl', 'cafile', $path.'/entrust_2048_ca.cer');

if($env)
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT else STREAM_CLIENT_PERSISTENT, $ctx);


if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);

$arrlength=count($registatoin_ids);

Log::useFiles(storage_path().'/logs/notification.log');

for($x=0;$x<$arrlength;$x++)

$finalArrayVal['aps'] = array(
'alert' => $title,
'badge' => $registatoin_ids[$x]['badge'],
'sound' => 'default'
);

foreach($finalArrayVal as $key => $value)
$finalArrayVal[$key] = array_map('strval', $finalArrayVal[$key]);


updateUserBadges($registatoin_ids[$x]['user_id'],$registatoin_ids[$x]['badge']);
$payload = json_encode($finalArrayVal);
$msg = chr(0) . pack('n', 32) . pack('H*', $registatoin_ids[$x]['device_id']) . pack('n', strlen($payload)) . $payload;

$result = fwrite($fp, $msg, strlen($msg));

if (!$result)
Log::info('Message not delivered at '.$x);
fclose($fp);
if($env) STREAM_CLIENT_PERSISTENT, $ctx);
else
$fp = stream_socket_client('tls://gateway.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT
else
Log::info('Message successfully delivered at '.$x);


fclose($fp)






php laravel push-notification apple-push-notifications






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 3:39









Prakash SutharPrakash Suthar

13




13












  • What version of PHP is it? According to github.com/reactphp/stream/issues/64 there was a bug in PHP that produced this same error that was fixed in in PHP 7.1.4 and 7.0.18. See here for a workaround: stackoverflow.com/questions/14695247/…

    – Mike
    Nov 16 '18 at 3:49


















  • What version of PHP is it? According to github.com/reactphp/stream/issues/64 there was a bug in PHP that produced this same error that was fixed in in PHP 7.1.4 and 7.0.18. See here for a workaround: stackoverflow.com/questions/14695247/…

    – Mike
    Nov 16 '18 at 3:49

















What version of PHP is it? According to github.com/reactphp/stream/issues/64 there was a bug in PHP that produced this same error that was fixed in in PHP 7.1.4 and 7.0.18. See here for a workaround: stackoverflow.com/questions/14695247/…

– Mike
Nov 16 '18 at 3:49






What version of PHP is it? According to github.com/reactphp/stream/issues/64 there was a bug in PHP that produced this same error that was fixed in in PHP 7.1.4 and 7.0.18. See here for a workaround: stackoverflow.com/questions/14695247/…

– Mike
Nov 16 '18 at 3:49













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331078%2ffwrite-ssl-operation-failed-with-code-openssl-error-messages-nerror1409f07f%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53331078%2ffwrite-ssl-operation-failed-with-code-openssl-error-messages-nerror1409f07f%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

政党

天津地下鉄3号線