I have got same questions in stackoverflow and tried all answers but no help. I am not getting what is the error.
Here is my function that i am using:
Thanks for replying I found similar solutions in google that you should write to socket again. In m case code was throwing exception so I am managing that. So Now I am doing it like this
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
try {
$result = fwrite($fp, $msg, strlen($msg));
}
catch (Exception $ex) {
// try once again for socket busy error (fwrite(): SSL operation failed with code 1.
// OpenSSL Error messages:\nerror:1409F07F:SSL routines:SSL3_WRITE_PENDING)
sleep(5); //sleep for 5 seconds
$result = fwrite($fp, $msg, strlen($msg));
if ($result)
{
return true;
}
else {
return false;
}
}
Now it is not throwing that error in most of the cases. What I found that it happens when socket is busy so I am trying to write again after 5 seconds now. So I guess this should not come again. It is not live yet but in our testing we did not found this issue again. Can you suggest that I am going in right direction? When this code will be live then there will be a huge number of push notifications then in that case will it work fine or is there any other solution in your mind? Thanks for help :)