Reputation: 9132
I'm trying to send push notification from my Java backend to my mobile app. For that, I'm using notnoop java-apns library. I managed to set everything up and everything works perfectly on Development (Development certificate and provisioning profile).
I want to release the app soon but first I wanted to setup everything so that I'm ready once it's live. So I created an 'App Store and Ad Hoc' certificate, and also an 'Ad Hoc' provisioning profile. Then I'm trying to use that P12 file which should be the same as the one I will be using once the app is live. But unfortunately I'm getting the following exception:
java.net.SocketException: Connection closed by remote host
at sun.security.ssl.SSLSocketImpl.checkWrite(SSLSocketImpl.java:1510)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
at java.io.OutputStream.write(OutputStream.java:75)
at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:328)
at com.notnoop.apns.internal.ApnsConnectionImpl.sendMessage(ApnsConnectionImpl.java:312)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:46)
at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:56)
at com.notnoop.apns.internal.ApnsServiceImpl.push(ApnsServiceImpl.java:36)
at com.notnoop.apns.internal.AbstractApnsService.push(AbstractApnsService.java:45)
.....
Anyone know what might be happening? How is it possible to work fine on Development but not AdHoc (and I'm guessing production as well, since they're using the same Push Notification certificate)?
Upvotes: 0
Views: 438
Reputation: 9132
I found the answer immediately after posting the question! Basically, in development mode I had the following code to initialize the service:
this.service = APNS.newService().withCert(p12Stream, passphrase).withSandboxDestination().build();
But, when using a production certificate, you can no longer using the sandbox destination but instead you need to use the following:
this.service = APNS.newService().withCert(p12Stream, passphrase).withProductionDestination().build();
Upvotes: 1