webpro2 / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

Receiving error-response packet with enhanced notification format #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I modified the code to send enhanced nofitication. As part of testing, I 
intentionally omitted device token in the raw packet, but still i did not 
receive any error packet back. I am using gateway.push.apple.com:2195.

Any thoughts and suggestions?

Many thanks.

Weiping

Original issue reported on code.google.com by wguo1...@gmail.com on 15 Apr 2011 at 7:54

GoogleCodeExporter commented 9 years ago
As per the Apple spec, the APNService accepts what is sent to it, and nothing 
is returned.

So what error packet would be returned?

Original comment by idbill.p...@gmail.com on 17 Apr 2011 at 4:33

GoogleCodeExporter commented 9 years ago
For enhanced notification format, "If you send a notification and APNs finds 
the notification malformed or otherwise unintelligible, it returns an 
error-response packet prior to disconnecting. (If there is no error, APNs 
doesn’t return anything.) ". APNs defines status code of 1-8 indicating 
different errors. 

I thought I should receive error response for missing device token, but I got 
nothing back. Just wonder in what kind of situation, error-response can be sent 
back by the APNs. 

Thanks.

Weiping

Original comment by wguo1...@gmail.com on 18 Apr 2011 at 2:27

GoogleCodeExporter commented 9 years ago
What you are looking for is the Feedback Service:

http://code.google.com/p/javapns/wiki/FeedbackBasicExample

Original comment by idbill.p...@gmail.com on 22 Apr 2011 at 9:18

GoogleCodeExporter commented 9 years ago
I think Feedback service is another issue. What I am looking for is error 
response, please see:

https://github.com/notnoop/java-apns/blob/master/src/main/java/com/notnoop/apns/
internal/ApnsConnectionImpl.java

Original comment by wguo1...@gmail.com on 23 Apr 2011 at 12:46

GoogleCodeExporter commented 9 years ago
This appears to be a new feature.

Original comment by idbill.p...@gmail.com on 25 Apr 2011 at 5:18

GoogleCodeExporter commented 9 years ago
The existing code uses the 'Simple notification format' which does not return 
an error EVER.

See docs at:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Concept
ual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html

I've tried updating to the 'Enhanced notification format' which is supposed to 
return an error, but I'm unable to get any errors back from the APNS.

With the Enhanced format, the connection isn't being dropped immediately after 
sending data, but I'm not getting anything back from my 
socket.getInputSocket.read() call.

This issue will have to be tabled until I have more time to troubleshoot.

Original comment by idbill.p...@gmail.com on 26 Apr 2011 at 12:44

GoogleCodeExporter commented 9 years ago
Thanks a lot for looking into it. I got the same result as yours. Maybe it has 
something to do with Apple Gateway. 

Weiping

Original comment by wguo1...@gmail.com on 26 Apr 2011 at 1:04

GoogleCodeExporter commented 9 years ago
Thanks a lot for looking into it. I got the same result as yours. Maybe it has 
something to do with Apple Gateway. 

Weiping

Original comment by wguo1...@gmail.com on 26 Apr 2011 at 1:04

GoogleCodeExporter commented 9 years ago

Original comment by sype...@gmail.com on 9 Sep 2011 at 7:20

GoogleCodeExporter commented 9 years ago
Re-labeling as an enhancement request.   

IMHO, since the library itself makes it difficult to push malformed 
notifications (validates tokens before push, JSON payload is generated 
programmatically, etc.), I believe the need for this is less relevant than if 
one were to write JSON payloads manually and then be more susceptible to 
payload format or content errors.  Still, it would be interesting to have 
support for this in a later version, even though the probability of receiving 
anything other than NO_ERROR is quite low because of how the library shields 
you from building invalid payloads.

Original comment by sype...@gmail.com on 14 Sep 2011 at 4:31

GoogleCodeExporter commented 9 years ago
Update:  javapns 2.0 Beta 4 includes full support for streaming messages with 
the enhanced notification format.  This was the first step in adding support 
for error packets.  

Additional note:  after review of 1.x code, it appears that the library did 
include a preliminary attempt at supporting error packets (this is what was 
freezing the library in the sendNotification method in 1.6).  However, the code 
never worked because it was executed within the same thread, instead of being 
delegated to a monitoring thread that is not blocking the notification thread.  
More work needs to be done to recover, adapt and enhance that code to support 
the requested feature.

Original comment by sype...@gmail.com on 15 Sep 2011 at 7:29

GoogleCodeExporter commented 9 years ago
Fixed in 2.0 Beta 5.

Details: 
All push methods now return response-enabled notification results (as 
javapns.notification.PushedNotification objects).  The new error-response 
packet reader automatically updates PushedNotification objects at the end of a 
connection so that you can find out what a transmission error was, if any 
occurred.

Original comment by sype...@gmail.com on 27 Sep 2011 at 1:20