Apple Push Notifications SSL Error

Had a similar problem in python, I guess the underlying ssl libraries are the same so the solution might be similar.

SSL3_WRITE_PENDING seems to be caused when a socket write fails then you try to write again. In this case for whatever reason SSL_write requires you to retry the write with the exact same bytes as the original write or else it omits the SSL_WRITE_PENDING error.

The pattern of errors I was seeing was Connection Timeout, then lots of SSL_WRITE_PENDING errors. This was because first one of my writes failed (say with maybe a timeout error or connection closed error because I send a dodgy push request), then after that error I was continually trying to re-use the broken socket (and it was giving back the less-than-informative SSL_WRITE_PENDING error)

Are you sure that you're using a new socket connection when you 'reconnect and resend'? Because I wouldn't have thought you should get SSL_WRITE_PENDING on a fresh socket connection to the APNS server.

Another thing that could help is using the enhanced notification format, because then if you accidentally send a broken push to the Apple server, it will send you an error code back before closing the connection on you. If you're not already using enhanced then it would be good to do so because then you can make sure you're not making simple errors like wrong token or payload too long things.