notnoop / java-apns

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

Notifications not being sent/ received on device #349

Open nates-dennis opened 6 years ago

nates-dennis commented 6 years ago

Recently started getting this error :

2017-11-16 16:14:00,626 [MonitoringThread-21] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - sendMessage Message(Id=1; Token=****; Payload={**Json Format ***) fromBuffer: true 2017-11-16 16:14:00,716 [MonitoringThread-21] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Connected new socket 617c3fce[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.push.apple.com/17.188.166.141,port=2195,localport=48067]] 2017-11-16 16:14:00,716 [MonitoringThread-21] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Launching Monitoring Thread for socket 617c3fce[SSL_NULL_WITH_NULL_NULL: Socket[addr=gateway.push.apple.com/17.188.166.141,port=2195,localport=48067]] 2017-11-16 16:14:00,716 [MonitoringThread-21] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Made a new connection to APNS 2017-11-16 16:14:00,716 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Started monitoring thread 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Error-response packet 08080000007C 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.Utilities - close 617c3fce[SSL_RSA_WITH_3DES_EDE_CBC_SHA: Socket[addr=gateway.push.apple.com/17.188.166.141,port=2195,localport=48067]] 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Closed connection cause=INVALID_TOKEN; id=1 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Candidate for removal, message id 1 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Bad message found 1 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - delegate.messageSendFailed, message id 1 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - resending 0 notifications 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - Monitoring input stream closed by EOF 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.Utilities - close 617c3fce[SSL_RSA_WITH_3DES_EDE_CBC_SHA: Socket[addr=gateway.push.apple.com/17.188.166.141,port=2195,localport=48067]] 2017-11-16 16:14:01,079 [MonitoringThread-22] DEBUG com.notnoop.apns.internal.ApnsConnectionImpl - draining buffer


Some background:

Here is how my code sends the APNS notification:

` String payload = null; try { ApnsService service = getService(tocCode);

        if (service != null) {

            payload = APNS.newPayload()
                    .sound("default")
                    .alertTitle(dataMap.get("title"))
                    .customFields(dataMap)
                    .alertBody(dataMap.get("message"))
                    .build();

            final Collection<? extends ApnsNotification> push = service.push(deviceids, payload);

            deleteInactiveDevices(service);

        } else {
            logger.error("Could not initialize APNS service );
        }`

Sometimes Push notification are going through and are being recived other times they are not and the above error is thrown . Can anyone please help with this ?