notnoop / java-apns

Java Apple Push Notification Service Provider
notnoop.github.com/java-apns
BSD 3-Clause "New" or "Revised" License
1.79k stars 657 forks source link

Apns Connection Sporadically Fails #264

Open tinamorris08 opened 8 years ago

tinamorris08 commented 8 years ago

I sporadically get connection refused errors. This happens in both the sandbox and production environments. I have all the required certificates and the ports are open through the firewall. This happens both when I send a message and contact the feedback service.

Here's an example of my code that connections to the feedback service:

ApnsServiceBuilder builder = getBuilder() .withCert("my cert path", my cert pw") .withAutoAdjustCacheLength(true) .withDelegate(getApnsErrorDelegate()) .withAppleDestination(isProductionDestination()); apnsService = builder.build(); service.getInactiveDevices();

And the error that is returned is: om.notnoop.exceptions.NetworkIOException: java.net.ConnectException: Connection refused: connect at com.notnoop.apns.internal.Utilities.wrapAndThrowAsRuntimeException(Utilities.java:285) at com.notnoop.apns.internal.ApnsFeedbackConnection.getInactiveDevices(ApnsFeedbackConnection.java:90) at com.notnoop.apns.internal.AbstractApnsService.getInactiveDevices(AbstractApnsService.java:132) at com.notnoop.apns.internal.ApnsServiceImpl.getInactiveDevices(ApnsServiceImpl.java:36) at com.efirstbank.pushnotification.rest.server.services.messaging.AppleMessagingService.getInactiveDevices(AppleMessagingService.java:87)

If I continue to run my code, I will get a valid connection.

Is this typical behavior? Should I expect that sometimes Apple will refuse my connection? Or should this work most of the time?

ThomBrando commented 8 years ago

Hey, Tina!

I'm having the same problem. Did you ever solve yours?