hengsokchamroeun / javapns

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

got stuck on pushManager.sendNotification( client, aPayload ); #54

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Have no file for 
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar
Have no file for 
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar
Have no file for 
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/sunrsasign.j
ar
Setting up Push notification
[2011-06-21 18:51:50,034]:[DEBUG]:[javapns.back.DeviceFactory] [?]- Adding 
badge [66]
[2011-06-21 18:52:13,360]:[DEBUG]:[javapns.back.DeviceFactory] [?]- Adding 
alert [You got an Alert from Astrazenica]
Payload setup successfull.
{"aps":{"alert":"You got an Alert from Astrazenica","badge":66}}
[2011-06-21 18:53:26,888]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Adding Token [f642d7a1eaada7a8450fd3802ca2dcae189edf4a9ec92ffd9e0dbec339261366] 
to Device [iPhone]
[2011-06-21 18:53:26,909]:[DEBUG]:[javapns.back.DeviceFactory] [?]- Get 
DeviceFactory Instance
[2011-06-21 18:53:26,916]:[DEBUG]:[javapns.back.DeviceFactory] [?]- Adding 
Token [f642d7a1eaada7a8450fd3802ca2dcae189edf4a9ec92ffd9e0dbec339261366] to 
Device [iPhone]
iPhone UDID taken.
[2011-06-21 18:54:19,531]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Getting Token from Device [iPhone]
[2011-06-21 18:54:19,532]:[DEBUG]:[javapns.back.DeviceFactory] [?]- Get 
DeviceFactory Instance
[2011-06-21 18:54:19,533]:[DEBUG]:[javapns.back.DeviceFactory] [?]- Getting 
Token from Device [iPhone]
Token: f642d7a1eaada7a8450fd3802ca2dcae189edf4a9ec92ffd9e0dbec339261366
[2011-06-21 18:54:37,189]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Getting Token from Device [iPhone]
[2011-06-21 18:54:37,196]:[DEBUG]:[javapns.back.DeviceFactory] [?]- Get 
DeviceFactory Instance
[2011-06-21 18:54:37,203]:[DEBUG]:[javapns.back.DeviceFactory] [?]- Getting 
Token from Device [iPhone]
Client setup successfull.
[2011-06-21 18:54:49,849]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Initializing Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195] 
with KeyStorePath 
[/Users/sahilkhanna/Documents/PushNotification/Certificates.p12]/[PKCS12]
[2011-06-21 18:54:58,388]:[DEBUG]:[javapns.back.SSLConnectionHelper] [?]- 
Instantiate SSLConnectionHelper with Path to Keystore
[2011-06-21 18:55:01,256]:[DEBUG]:[javapns.back.SSLConnectionHelper] [?]- 
Creating SSLSocketFactory
[2011-06-21 18:55:01,918]:[DEBUG]:[javapns.back.SSLConnectionHelper] [?]- 
Returning Push SSLSocketFactory
[2011-06-21 18:55:01,919]:[DEBUG]:[javapns.back.SSLConnectionHelper] [?]- 
Returning Push SSLSocket
Connection initialized...
[2011-06-21 18:55:33,217]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Building Raw message from deviceToken and payload
[2011-06-21 18:55:33,233]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Attempting to send Notification [{"aps":{"alert":"You got an Alert from 
Astrazenica","badge":66}}]
[2011-06-21 18:55:33,240]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Building Raw message from deviceToken and payload
[2011-06-21 18:55:37,351]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Flushing
[2011-06-21 18:55:37,352]:[DEBUG]:[javapns.back.PushNotificationManager] [?]- 
Notification sent

here the code is stuck and aim not getting any notification

Original issue reported on code.google.com by ankurchh...@gmail.com on 21 Jun 2011 at 1:38

GoogleCodeExporter commented 8 years ago
The debugging message 'Notification sent' indicates.... the notification was 
successfully sent.

Check your iPhone code.

Original comment by idb...@pugetworks.com on 21 Jun 2011 at 9:12

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi, I am having the same issue. Good Google (as I write, this thread is only 42 
hours old). I give you some additional information and clarify the problem 
(notification does not arrive, but even worse: server is stuck in 
sendNotification 

The Code looks something like that (actually almost the example):

String absCertName = getServletContext().getRealPath(relativeCertificateName);
log.debug("doPost():initializeConnection:" + appleHost + " " + applePort + " " 
+ absCertName + " " + certificatePassword);
pushManager.initializeConnection(appleHost, applePort, absCertName, 
certificatePassword, SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
log.debug("Connection initialized...");
pushManager.sendNotification(client, aPayLoad);
log.info("doPost(): message send with no of attempts: " + 
pushManager.getRetryAttempts());
pushManager.stopConnection();
resp.getOutputStream().println(.....);

The log-output shows the following:
[23.06.2011 10:22:28] DEBUG de.me.pushserver.web.SendNotificationServlet - 
doPost():initializeConnection:gateway.sandbox.push.apple.com 2195 
/Volumes/projects/....../devPush.p12
[23.06.2011 10:22:28] DEBUG javapns.back.PushNotificationManager - Initializing 
Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195] with 
KeyStorePath [/Volumes/projects/...../devPush.p12]/[PKCS12]
[23.06.2011 10:22:28] DEBUG javapns.back.SSLConnectionHelper - Instantiate 
SSLConnectionHelper with Path to Keystore
[23.06.2011 10:22:28] DEBUG javapns.back.SSLConnectionHelper - Creating 
SSLSocketFactory
[23.06.2011 10:22:28] DEBUG javapns.back.SSLConnectionHelper - Returning Push 
SSLSocketFactory
[23.06.2011 10:22:28] DEBUG javapns.back.SSLConnectionHelper - Returning Push 
SSLSocket
[23.06.2011 10:22:29] DEBUG de.me.pushserver.web.SendNotificationServlet - 
Connection initialized...
[23.06.2011 10:22:29] DEBUG javapns.back.PushNotificationManager - Building Raw 
message from deviceToken and payload
[23.06.2011 10:22:29] DEBUG javapns.back.PushNotificationManager - Attempting 
to send Notification [{"aps":{"alert":"helo","badge":66}}]
[23.06.2011 10:22:29] DEBUG javapns.back.PushNotificationManager - Building Raw 
message from deviceToken and payload
[23.06.2011 10:22:29] DEBUG javapns.back.PushNotificationManager - Flushing
[23.06.2011 10:22:29] DEBUG javapns.back.PushNotificationManager - Notification 
sent

So I never see the the log-output
log.info("doPost(): message send with no of attempts: " + 
pushManager.getRetryAttempts());
and I guess that the message
pushManager.sendNotification(client, aPayLoad);
does not return. I do not get the message on the phone either (but that is 
follow-up problem). The server hangs in the message sendNotification

What version of the product are you using? On what operating system?
Lets see, some facts: I am on OSX 10.6.7, JDK 1.6.0_24 running within a 
Glassfish 3 out of NetBeans 6.9.1

Libraries are exactly like stated in the wiki (added commons-logging for me):
WEB-INF/lib sb$ ls -1
bcprov-jdk16-1.45.jar
commons-io-1.4.jar
commons-lang-2.4.jar
commons-logging-1.1.jar
javapns-jdk16-168.jar
log4j-1.2.15.jar

Running the exact same code on Tomcat 6.0.18 and jdk1.6.0_24 and a new 
OpenSolaris version, it crashes:

[23.06.2011 02:10:21] DEBUG de.me.pushserver.web.SendNotificationServlet - 
doPost():initializeConnection:gateway.sandbox.push.apple.com 2195 
/home/...../devPush.p12 
[23.06.2011 02:10:21] DEBUG javapns.back.PushNotificationManager - Initializing 
Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195] with 
KeyStorePath [/home...../devPush.p12]/[PKCS12]
[23.06.2011 02:10:21] DEBUG javapns.back.SSLConnectionHelper - Instantiate 
SSLConnectionHelper with Path to Keystore
[23.06.2011 02:10:21] DEBUG javapns.back.SSLConnectionHelper - Creating 
SSLSocketFactory
[23.06.2011 02:10:21] DEBUG javapns.back.SSLConnectionHelper - Returning Push 
SSLSocketFactory
[23.06.2011 02:10:21] DEBUG javapns.back.SSLConnectionHelper - Returning Push 
SSLSocket
[23.06.2011 02:10:21] WARN de.me.pushserver.web.SendNotificationServlet - 
doPost(): got Throwable: java.net.ConnectException with message: Connection 
refused
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:529)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:559)
        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(SSLSocketImpl.java:360)
        at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
        at javapns.back.SSLConnectionHelper.getSSLSocket(Unknown Source)
        at javapns.back.PushNotificationManager.initializeConnection(Unknown Source)
        at de.me.pushserver.web.SendNotificationServlet.doPost(SendNotificationServlet.java:103)

Original comment by sebastia...@gmail.com on 23 Jun 2011 at 9:19

GoogleCodeExporter commented 8 years ago
I just want to be sure that it is not a classloader issue. Therefore I have 
extracted the code into a simple CLI program for testing and I get the same 
behavior on both systems. Furthermore, I have tried another framework to be 
sure that the apple certificates are correct (java-apns) and it runs on the 
OSX, but not on the Solaris Server.

I am going to invest a little more how the connections are opened to get a 
better understanding.

Original comment by sebastia...@gmail.com on 24 Jun 2011 at 9:01

GoogleCodeExporter commented 8 years ago
I'm having the same issue with the working example CLI example in the wiki. It 
hangs on sendNotification and the log says DEBUG 
javapns.back.PushNotificationManager - Notification sent but the device 
receives no notification.

How did you generate your key? javapns seens to require the .p12 key, whereas 
other implementations (ex: one I found in PHP) wants a .pem.

Original comment by ben%unfi...@gtempaccount.com on 24 Jun 2011 at 2:18

GoogleCodeExporter commented 8 years ago
The key was generated the way stated in 
http://code.google.com/p/javapns/wiki/GetAPNSCertificate

But I am sure that the .p12 is correct (works with other framework (at least on 
OSX)

Original comment by sebastia...@gmail.com on 24 Jun 2011 at 2:48

GoogleCodeExporter commented 8 years ago
That's also the way I generated mine.

I did a quick test with a simple PHP script by following 
http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part
-12  and generated a .pem from my certificate and key and I'm able to send push 
notifications. I can also send them from a Ruby script with the same .pem. 
Therefore, I assume my cert is ok and my ports are all open. I'm have no idea 
why it hangs on sendNotification.

Original comment by ben%unfi...@gtempaccount.com on 24 Jun 2011 at 2:55

GoogleCodeExporter commented 8 years ago
I tested on another opensolaris vm (may be a little older but with same jdk 
version. there, it works. I'm going to both truss outputs and try to compare....

Original comment by sebastia...@gmail.com on 24 Jun 2011 at 4:30

GoogleCodeExporter commented 8 years ago
same issue here, but in the ios debugger console, i saw the 
didReceiveRemoteNotification was triggered, but the information inside were as 
below

key: aps, value : {}

Original comment by jinmiss...@gmail.com on 27 Jun 2011 at 10:53

GoogleCodeExporter commented 8 years ago
tested on 16.161 with the same code was working...

Original comment by jinmiss...@gmail.com on 28 Jun 2011 at 2:07

GoogleCodeExporter commented 8 years ago
Same problem for me with release 16.168
Works with 16.161 

Original comment by francois...@gmail.com on 29 Jun 2011 at 9:44

GoogleCodeExporter commented 8 years ago
Hi,

I invested a little more in the CLI. Here is a stacktrace while the program 
hangs:

Full thread dump Java HotSpot(TM) 64-Bit Server VM (19.1-b02-334 mixed mode):

"Poller SunPKCS11-Darwin" daemon prio=1 tid=102a7f800 nid=0x10a50c000 waiting 
on condition [10a50b000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at sun.security.pkcs11.SunPKCS11$TokenPoller.run(SunPKCS11.java:692)
    at java.lang.Thread.run(Thread.java:680)

"Low Memory Detector" daemon prio=5 tid=1018a7800 nid=0x109f13000 runnable 
[00000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread1" daemon prio=9 tid=1018a7000 nid=0x109e10000 waiting on 
condition [00000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=9 tid=1018a6000 nid=0x109d0d000 waiting on 
condition [00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=9 tid=1018a5800 nid=0x109c0a000 waiting on 
condition [00000000]
   java.lang.Thread.State: RUNNABLE

"Surrogate Locker Thread (CMS)" daemon prio=5 tid=1018a4800 nid=0x109b07000 
waiting on condition [00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=10189c000 nid=0x1097fc000 in Object.wait() 
[1097fb000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <7f44e0860> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:118)
    - locked <7f44e0860> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=10189b000 nid=0x1096f9000 in 
Object.wait() [1096f8000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <7f44e0878> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:485)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
    - locked <7f44e0878> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=101801000 nid=0x100501000 runnable [100500000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
    at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:798)
    - locked <7f458cca0> (a java.lang.Object)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:755)
    at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75)
    - locked <7f40b9128> (a com.sun.net.ssl.internal.ssl.AppInputStream)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
    - locked <7f40b9110> (a java.io.InputStreamReader)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at java.io.BufferedReader.fill(BufferedReader.java:136)
    at java.io.BufferedReader.readLine(BufferedReader.java:299)
    - locked <7f40b9110> (a java.io.InputStreamReader)
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    at javapns.back.PushNotificationManager.sendNotification(Unknown Source)
    at PushTest.main(PushTest.java:61)

"VM Thread" prio=9 tid=101896800 nid=0x1095f6000 runnable 

"Gang worker#0 (Parallel GC Threads)" prio=9 tid=101802800 nid=0x102201000 
runnable 

"Gang worker#1 (Parallel GC Threads)" prio=9 tid=101803000 nid=0x102304000 
runnable 

"Concurrent Mark-Sweep GC Thread" prio=9 tid=10184d800 nid=0x109302000 runnable 
"VM Periodic Task Thread" prio=10 tid=1018b9800 nid=0x10a016000 waiting on 
condition 

"Exception Catcher Thread" prio=10 tid=101801800 nid=0x10176a000 runnable 
JNI global references: 1472

Heap
 par new generation   total 19136K, used 4576K [7f3000000, 7f44c0000, 7f44c0000)
  eden space 17024K,  22% used [7f3000000, 7f33ab588, 7f40a0000)
  from space 2112K,  38% used [7f40a0000, 7f416ce08, 7f42b0000)
  to   space 2112K,   0% used [7f42b0000, 7f42b0000, 7f44c0000)
 concurrent mark-sweep generation total 63872K, used 4381K [7f44c0000, 7f8320000, 7fae00000)
 concurrent-mark-sweep perm gen total 21248K, used 8646K [7fae00000, 7fc2c0000, 800000000)

I believe the most important lines are these:
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    at javapns.back.PushNotificationManager.sendNotification(Unknown Source)

Therefore I enabled logging 

[29.06.2011 17:44:38] DEBUG javapns.back.DeviceFactory - Adding badge [66]
[29.06.2011 17:44:38] DEBUG javapns.back.PushNotificationManager - Adding Token 
[xxx] to Device [iPhone]
[29.06.2011 17:44:38] DEBUG javapns.back.DeviceFactory - Get DeviceFactory 
Instance
[29.06.2011 17:44:38] DEBUG javapns.back.DeviceFactory - Adding Token [xxx] to 
Device [iPhone]
[29.06.2011 17:44:38] DEBUG javapns.back.PushNotificationManager - Getting 
Token from Device [iPhone]
[29.06.2011 17:44:38] DEBUG javapns.back.DeviceFactory - Get DeviceFactory 
Instance
[29.06.2011 17:44:38] DEBUG javapns.back.DeviceFactory - Getting Token from 
Device [iPhone]
[29.06.2011 17:44:38] DEBUG javapns.back.PushNotificationManager - Getting 
Token from Device [iPhone]
[29.06.2011 17:44:38] DEBUG javapns.back.DeviceFactory - Get DeviceFactory 
Instance
[29.06.2011 17:44:38] DEBUG javapns.back.DeviceFactory - Getting Token from 
Device [iPhone]
[29.06.2011 17:44:38] DEBUG javapns.back.PushNotificationManager - Initializing 
Connection to Host: [gateway.sandbox.push.apple.com] Port: [2195] with 
KeyStorePath [xxx.p12]/[PKCS12]
[29.06.2011 17:44:38] DEBUG javapns.back.SSLConnectionHelper - Instantiate 
SSLConnectionHelper with Path to Keystore
[29.06.2011 17:44:38] DEBUG javapns.back.SSLConnectionHelper - Creating 
SSLSocketFactory
[29.06.2011 17:44:38] DEBUG javapns.back.SSLConnectionHelper - Returning Push 
SSLSocketFactory
[29.06.2011 17:44:38] DEBUG javapns.back.SSLConnectionHelper - Returning Push 
SSLSocket
[29.06.2011 17:44:39] DEBUG javapns.back.PushNotificationManager - Building Raw 
message from deviceToken and payload
[29.06.2011 17:44:39] DEBUG javapns.back.PushNotificationManager - Attempting 
to send Notification [{"aps":{"badge":66}}]
[29.06.2011 17:44:39] DEBUG javapns.back.PushNotificationManager - Building Raw 
message from deviceToken and payload
[29.06.2011 17:44:40] DEBUG javapns.back.PushNotificationManager - Flushing
[29.06.2011 17:44:40] DEBUG javapns.back.PushNotificationManager - Notification 
sent

As we see, the last log-entry is "Notification sent". 

Therefore, I have looked at the code (with diff):
http://code.google.com/p/javapns/source/diff?spec=svn158&old=110&r=153&format=si
de&path=%2Ftrunk%2Fsrc%2Fjavapns%2Fback%2FPushNotificationManager.java

It hangs in line
161: logger.debug( "In: [" + in.readLine() + "]" );

The BufferedReader has just been introduced. I believe mainly to read the 
response for better error detection. I still don't know why it hangs. I could 
imagine the following:
-  the response data does not contain a newline (carriage return), therefore 
(maybe only on some plattforms (or plattform versions) th  readLine()-Method on 
a socket might not return (How should the response  look like?)
- different behavior on different OS for Socket (or SSLSocket)

I guess it would be a good idea, to simple use read()-Method since the response 
is only used for informational output (btw: the use of System.out.println is 
not really good for any productive usage because you write lots of data to a 
file which can not be rotated and the JVM needs to be restarted (once in a 
while before your filesystem runs out of space) which means a downtime....)

I know, I should fix that myself instead of crying, but I don't want to get 
into that topic.

Original comment by sebastia...@gmail.com on 29 Jun 2011 at 4:14

GoogleCodeExporter commented 8 years ago
Hi, I just started working with this project yesterday and ran into the same 
issue.  sebastia, you right, i checked the apple documentation, if the request 
was successful, no output is sent back. Furthermore the connection is not 
severed as apple expects providers to re-use these connection.  It would 
actually be much better if they returned anything on success, the code would 
simpler to always expect something, but Apple clearly designed this for very 
high volume and throughput (i can only imagine how many message someone like 
ESPN sends at the end of a big game)

The code probably needs to be re-factored to operate in a more asynchronous 
manner, a run loop that alternates sending messages from a local queue (like a 
synchronized linked list)  and checking if data is available to be read from 
apple (and call back an error handler).  The binary format has a unique 
identifier (which is hard coded right now to "ap") to correlate failures which 
indicates that the response may not be immediate. 

Original comment by digital...@gmail.com on 1 Jul 2011 at 2:23

GoogleCodeExporter commented 8 years ago
Same here.
Just started using the library and facing such an issue.
Anyway, before the code starts waiting for anything to read in the input 
socket, it should have sent the notification, right?
Therefore, even if the library needs to be refactored and is not usable at all 
at the moment, do you receive any notification on your device? I don't :(

Thanks,
Luca

Original comment by dnt.l...@gmail.com on 6 Jul 2011 at 11:16

GoogleCodeExporter commented 8 years ago
Luca, I'm using 16.161 which is working fine for me right now.  Its not 
checking for failures, but I don't really need that functionality right now

Original comment by dan.cunn...@gmail.com on 12 Jul 2011 at 4:54

GoogleCodeExporter commented 8 years ago
same here, program hangs at sendNotification(client, payload) when using 16.168
switched to 16.161 and got the notifications
thank you guys! 

Original comment by alan...@gmail.com on 14 Jul 2011 at 2:34

GoogleCodeExporter commented 8 years ago
Has this issue been resolved for 16.168 becasue its happening to me as well.

Original comment by sguerr...@gmail.com on 24 Jul 2011 at 7:26

GoogleCodeExporter commented 8 years ago
The issue stems from the following funtion:
public void sendNotification(Device device, PayLoad payload) 

It seems that the bufferedreader has NULL
BufferedReader in = new BufferedReader( new InputStreamReader( 
this.socket.getInputStream() ) );

So when this portion of the code gets hit it just hangs there in endless loop

logger.debug( "In: [" + in.readLine() + "]" );
This output is [null]

So then right after then the loops get executed:                
while ( ! this.socket.isInputShutdown() ) {
    while( in.ready() ) {
        logger.debug("ready now");
        logger.debug(in.readLine());
        System.out.println( this.socket.getInputStream().read() );
    }
}

The code enters the first while loop and waits for the BufferedReader in to be 
ready
and just keeps waiting..... ad that is your hanging

Original comment by sguerr...@gmail.com on 24 Jul 2011 at 8:58

GoogleCodeExporter commented 8 years ago
I removed the in.readLine debugging and most of the println(s).. some were 
converted to logger statements.

Thank you for pointing this out.

Original comment by idbill.p...@gmail.com on 25 Jul 2011 at 9:44

GoogleCodeExporter commented 8 years ago
Question: I get the desires output
 Setting up Push notification  
Payload setup successfull.  
{"aps":{"badge":66}}  
iPhone UDID taken.  
Token: 2ed202ac08ea9033665e853a3dc8bc4c5e78f7a6cf8d55910df230567037dcc4  
Client setup successfull.  
Connection initialized...  
Message sent!  
# of attempts: 3  
done

But I never get a notification on the actual device! Does anyone have a 
solution for this?

Sergio

Original comment by sguerr...@gmail.com on 26 Jul 2011 at 3:43

GoogleCodeExporter commented 8 years ago
I was using 16-169 version and had exactly same prob,

after looking all the comments above I tried 16-165 version

It worked and no stucking at all
got normal output as below and notification on device!!
Client setup successfull.
Connection initialized...
Message sent!
# of attempts: 3
done

What's new in 16-169 which is not in 16-165??

Original comment by nadeem.k...@gmail.com on 9 Aug 2011 at 7:36

GoogleCodeExporter commented 8 years ago
Yes, me too.

I encountered the problem sometimes, by 16-165.
And I upgraded to 16-169, the problem become more frequent.

So, I just fallback to 16-165 now.
But the problem still exists.

Original comment by janchan...@gmail.com on 10 Aug 2011 at 12:13

GoogleCodeExporter commented 8 years ago
Regarding the issue in 16-169 with notifications that appear to be sent but 
never actually make it to the device, revision r153 introduced a bug in the 
PushNotificationManager's sendNotification method which causes the library to 
ignore actual Payloads it is given and instead try to push a blank payload (the 
sendNotification method actually creates a new Payload() object and pushes that 
one).  I'm guessing that some temporary test code was committed indadvertedly.

A fix has been applied to the 2.0 branch.  Since I'm only working in that 
branch, I will let other developers fix this in the trunk...

As for the issue with the library getting stuck in the sendNotification() 
method, I have disabled (in 2.0) the code that attempts to drain data from the 
socket immediately after the notification has actually been sent, and now 
everything seems to be pushing fine.  Again, I'll let other developers fix this 
in the trunk...  but if you need it fast, the fix is in the "javapns2" branch.

Original comment by sype...@gmail.com on 31 Aug 2011 at 10:04

GoogleCodeExporter commented 8 years ago
Java Exception: java.net.ConnectException: Connection refused: connect: during 
call of javapns.back.PushNotificationManager.initializeConnection. (2,763) 
IP_JAVA_TEST.MAIN.GBL.default.1900-01-01.Step01.OnExecute  PCPC:1315  
Statement:10

I am getting this error, I am inovking the java code from peoplecode, 
Peoplecode has native language support to java. Certificate is *.p12 file and 
it is correct with proper password. Port on the system is opened correctly for 
connection.

Please help to solve this issues

Original comment by ganesh....@gmail.com on 7 Sep 2011 at 10:59

GoogleCodeExporter commented 8 years ago
As per comment c23, I am closing the issue as Fixed in 2.0.

ganesh.mvj, you seem to be reporting a different issue.... please create a new 
issue if that is the case.  Thanks!

Original comment by sype...@gmail.com on 7 Sep 2011 at 4:22