rc = Provided.valueOf("NEVER");
service = APNS.newService().asPool(1).withReconnectPolicy(rc).withCert(certPathBase+"APNSCertificates.p12", "password").withSandboxDestination().build();
Is this correct? I can verify the connection remains open for 2 hours when not pushing notifications. However, when a new notification is pushed the existing connection is closed and a new connection openend.
It's entirely possible my implementation of the library is causing this, but right now it is difficult to verify.
Thanks for reporting your findings. However, testing the re-usability
of connection is a bit tricky.
When a connection is not used for a long time (e.g. in my environment
around 30 minutes), the connection might go stale. It is possible
that one of the servers or one of the intermediate routers/switches
will close it to free up some resources. In such cases, the
application may not detect that the connection actually closed (not
even with `connection.isClosed()`) until something is actually written
to the wire.
In your test scenario, it is very probable that the connection was
actually closed sometime within the two hours, but only got detected
as closed after the two hours of inactivity, when a message was about
to be written on the wire.
Check out the following article for more details:
http://www.codeproject.com/Articles/37490/Detection-of-Half-Open-Dropped-TCP-IP-Socket-Conne
.
In any case, this shouldn't be an issue with Apple. If you are
reconnecting only if you go stale (or once every 30 minutes), you
should be fine. Apple just doesn't want you to reconnect tens of
times a second.
- Mahmood