intermittent ClientNotConnectedException errors not fixed by getReconnectionFuture().await()

188 views
Skip to first unread message

Javier Vegas

unread,
Jun 27, 2017, 10:20:47 PM6/27/17
to pushy

I just updated to pushy-0.10 and most of my pushes are being sending fine, but sometimes I am seeing this errors

java.util.concurrent.ExecutionException: com.turo.pushy.apns.ClientNotConnectedException
        at io.netty.util.concurrent.AbstractFuture.get(AbstractFuture.java:41)
        at com.nuzzel.external.ApplePnsClient.sendPushNotification(ApplePnsClient.java:190)
        at com.nuzzel.external.ApplePnsClient.sendPushNotification(ApplePnsClient.java:162)
        at com.nuzzel.messaging.StoryPushNotificationTask.doRun(StoryPushNotificationTask.java:101)
        at com.nuzzel.framework.persistence.QueuedTask.run(QueuedTask.java:34)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: com.turo.pushy.apns.ClientNotConnectedException
        at com.turo.pushy.apns.ApnsClient.<clinit>(ApnsClient.java:152)
        at com.turo.pushy.apns.ApnsClientBuilder.build(ApnsClientBuilder.java:420)here...

I am catching ClientNotConnectedException and retrying the sendPushNotification

} catch (InterruptedException | ExecutionException ex) {
      if (ex.getCause() instanceof ClientNotConnectedException) {
        try {
          apnsClient.getReconnectionFuture().await();
          Logger.logWarning("APNS: Reconnected.");
          // retry
          if (attemptNumber < 4) {
            return sendPushNotification( apnsClient, body, device);
          }
        } catch (InterruptedException ex1) {
          Logger.logException(ex1);
        }
      }

but in those cases the  apnsClient.getReconnectionFuture().await(); does not seem to fix the connection, and I get into a recursive loop that ends in a StackOverflow. I have fixed my code to have a limit in the number of retries, but is there anything I can do to avoid dropping pushes when I get in this situation? I am in a multithreaded environment, with a shared apnsClient shared by several threads all of them trying to send pushes. Is that the right approach?

Thanks,

Javier Vegas


Jon Chambers

unread,
Jun 28, 2017, 9:30:44 AM6/28/17
to Javier Vegas, pushy
This sounds a lot like https://github.com/relayrides/pushy/issues/454. I don't think you're doing anything wrong; this problem is most apparent if (a) you have a really bad network connection (often the case in China, sadly) or (b) you're using TLS authentication and your certificate has expired.

We're definitely aware of the issue and hope to have a fix soon.

-Jon

--
Pushy is an open-source Java library for sending APNs (iOS and OS X) push notifications. Pushy is brought to you by the engineers at RelayRides.
---
You received this message because you are subscribed to the Google Groups "pushy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Javier Vegas

unread,
Jun 28, 2017, 3:49:51 PM6/28/17
to pushy, jav...@nuzzel.com
In my case, my connection is good (I am hosted at AWS US East zone) and my certificate has not expired, the ClientNotConnectedException problem is only intermittent and reconnection seems to fail for a while after the first ClientNotConnectedException appears but also seems to fix by itself after some time, so seems like a different issue from 454  
To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+...@googlegroups.com.

Jon Chambers

unread,
Jun 28, 2017, 3:50:23 PM6/28/17
to Javier Vegas, pushy
Interesting. Thanks for clarifying; I'll take a closer look!

-Jon

To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages