Skip Menu |

This queue is for tickets about the Net-APNS-Persistent CPAN distribution.

Report information
The Basics
Id: 54884
Status: new
Priority: 0/
Queue: Net-APNS-Persistent

People
Owner: Nobody in particular
Requestors: agrow [...] iobound.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.01
  • 0.01b
  • 0.01c
  • 0.01d
  • 0.02
Fixed in: (no value)



Subject: SIGPIPE if gateway server closes ssl connection
Mark, First off, thanks for Net::APNS::Persistent. We've noticed that the APN gateway server will explicitly close the ssl connection if you send an unrecognized device token (eg a sandbox token to the production gateway), and that this results in sudden death by SIGPIPE. It would be cool if there was some way for Net::APNS::Persistent to detect this condition before attempting an ssl_write_all, but I'm not sure Net::SSLeay exposes enough of the ssl layer for you to do this. So maybe for now, just put a caveat in the perldoc? (Patch attached.) There is an implication in the perldoc that you can catch and deal with any ssl layer error, so the SIGPIPE is a bit of a surprise. "All methods are fatal on error. Eg. if the ssl connection returns an error, the code will die. You can either then just restart your script or you can use eval to catch the exception."
Subject: sigpipe-perldoc.diff
diff --git a/lib/Net/APNS/Persistent.pm b/lib/Net/APNS/Persistent.pm index 30eb8dd..63bfe94 100644 --- a/lib/Net/APNS/Persistent.pm +++ b/lib/Net/APNS/Persistent.pm @@ -81,6 +81,23 @@ All methods are fatal on error. Eg. if the ssl connection returns an error, the code will die. You can either then just restart your script or you can use C<eval> to catch the exception. +Note that the APN gateway server may explicitly close the ssl connection +before all queued data can be written to the socket, resulting in a SIGPIPE on +POSIX platforms. The most common cause of this is sending an unrecognized device +token. In particular, sending sandbox device tokens to a production gateway +server, and vice versa, may cause the server to close the connection. + +To make an explicit server close more obvious and/or catchable with C<eval>, +you can do something like this: + + { + local $SIG{PIPE} = sub { + die "sigpipe error - server closed ssl connection."; + }; + + $apns->send_queue; + } + =head1 DESCRIPTION Class to create a persistent connection to Apple's APNS servers