Closed GoogleCodeExporter closed 9 years ago
2.0 Beta 4 did not include any support for reading error-response packets, so
it would not have been affected by this more recent read process (but obviously
2.0b4 wouldn't provide accurate error reports because of that missing process).
However, the library we have today is supposed to request a short timeout so
not to block indefinitely, so a thread stuck on read for 5 minutes is not
behaving as expected.
Could you try the latest 2.3 Alpha build from the trunk and let me know if you
still experience the issue with it? Some work has been done recently around
error-response packets in JavaPNS, so the issue might already be fixed.
Btw, if you don't care about error-response packets, you can disable the
enhanced notification format entirely by invoking
PushNotificationManager.setEnhancedNotificationFormatEnabled(false); (although
this is not recommended because you turn off error management and loose that
precious source of error information).
Original comment by sype...@gmail.com
on 11 Apr 2012 at 1:15
Note: It's 5 SECONDS, not minutes. But, our GAE server that calls over to our
push-server times out after 30 seconds, so it's causing issues.
I just tried 2.3-Alpha4 and get the same results:
2012-04-10 19:57:50 Payload [DEBUG] Adding custom Dictionary [data.type] =
[testmsg]
2012-04-10 19:57:50 PushNotificationService [INFO] Pushing with Payload:
{"aps":{"sound":"default","alert":"testing","badge":1},"data.type":"testmsg"}
2012-04-10 19:57:50 ConnectionToAppleServer [DEBUG] Creating SSLSocketFactory
2012-04-10 19:57:50 ConnectionToAppleServer [DEBUG] Creating SSLSocket to
gateway.sandbox.push.apple.com:2195
2012-04-10 19:57:50 PushNotificationManager [DEBUG] Initialized Connection to
Host: [gateway.sandbox.push.apple.com] Port: [2195]:
64626fd2[SSL_NULL_WITH_NULL_NULL:
Socket[addr=gateway.sandbox.push.apple.com/17.149.34.66,port=2195,localport=5045
3]]
2012-04-10 19:57:50 PushNotificationManager [DEBUG] Building Raw message from
deviceToken and payload
2012-04-10 19:57:50 PushNotificationManager [DEBUG] Built raw message ID 1 of
total length 122
2012-04-10 19:57:50 PushNotificationManager [DEBUG] Attempting to send
notification:
{"aps":{"sound":"default","alert":"testing","badge":1},"data.type":"testmsg"}
2012-04-10 19:57:50 PushNotificationManager [DEBUG] to device:
8a662fa8e2d7c6bd6c309941f1b14c354286cd3aeb26e01e37dbd2af339af044
2012-04-10 19:57:50 PushNotificationManager [DEBUG] Flushing
2012-04-10 19:57:50 PushNotificationManager [DEBUG] At this point, the entire
122-bytes message has been streamed out successfully through the SSL connection
2012-04-10 19:57:50 PushNotificationManager [DEBUG] Notification sent on first
attempt
2012-04-10 19:57:50 PushNotificationManager [DEBUG] Reading responses
//// 5 seconds here
2012-04-10 19:57:55 PushNotificationManager [DEBUG] Closing connection
2012-04-10 19:57:55 PushNotificationService [DEBUG] Devices Size of Push: 1
2012-04-10 19:57:55 DispatcherServlet [DEBUG] Null ModelAndView returned to
DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed
request handling
2012-04-10 19:57:55 DispatcherServlet [DEBUG] Successfully completed request
Original comment by dustin.b...@gmail.com
on 11 Apr 2012 at 2:00
Ah, 5 seconds sounds much better than 5 minutes :)
5 seconds is indeed the hardcoded timeout necessary to make sure that no more
response packets are coming in. This specific timeout was selected after a lot
of field testing, so it is pretty much a fine-tuned value which should not be
changed. Since reading is done inline within the same thread, and since Apple
servers to not shut down the stream on their end when the socket is closed,
read timeout seems to be unavoidable. The timeouts are trapped and ignored,
but the delay before a timeout occurs can be perceived, as you did.
If you push a single notification at a time and that you can't do it
asynchronously, I agree that the delay might be problematic. For now, the only
way to avoid the delay is to turn off the enhanced notification format as per
my previous comment. There are plans to eventually move the error-response
packet reading mechanism to a separate thread to avoid the delay, but it is not
as easy as it sounds because push methods returning immediately would not yet
know about the errors coming in asynchronously a few milliseconds or seconds
later from the other thread...
Original comment by sype...@gmail.com
on 11 Apr 2012 at 3:01
Since the 5-seconds delay is necessary to give Apple servers time to return
error-response packets, if any, I am closing this issue as WontFix because it
is an APNS design issue rather than an issue with JavaPNS.
Original comment by sype...@gmail.com
on 21 Apr 2012 at 5:08
Original issue reported on code.google.com by
dustin.b...@gmail.com
on 10 Apr 2012 at 11:38