jravindra / javapns

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

Request not even being sent #167

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

public PushedNotifications sendMessage(String[] devices, String apnsMsg, int 
badge, String tone, String locAction) throws Exception
{
    PushedNotifications pushedNotifications = null;
    int numDevices = devices.length;    //get the number of tokens
    long start = System.currentTimeMillis();

    if(numDevices > 0)
    {
        if(StringUtil.isStringEmpty(tone))
        {   
            //if tone is not given, set it to default tone
            tone = "default";
        }

        //prepare the payload with message, badge and tone given,
        PushNotificationPayload payload = PushNotificationPayload.complex();
        payload.addBadge(badge);
        payload.addSound(tone);
        payload.addCustomAlertBody(apnsMsg);
        payload.addCustomAlertActionLocKey(locAction);

        //get the certificate path from given cert filename
        String certPath = getClass().getClassLoader().getResource(certFile).getPath();  

        //replace all whitespace character with %20, since URL object contains "%20" instead of " "
        certPath = certPath.replaceAll("%20", " "); 

        logger.info("About to push notifications: " + (System.currentTimeMillis() - start));

        try {
            logger.info("About to create push queue: " + (System.currentTimeMillis() - start));

            if(queue == null)
            {
                queue = Push.queue(certPath, certPass, isProd, numThreads);
            }
            logger.info("Starting queue: " + (System.currentTimeMillis() - start));
            queue.start();
            logger.info("Queue started: " + (System.currentTimeMillis() - start));
            for(int i = 0; i < numDevices; ++i)
            {
                queue.add(payload, devices[i]);
            }
            pushedNotifications = queue.getPushedNotifications();
            logger.info("Notifications pushed: " + pushedNotifications.size() + " at " + (System.currentTimeMillis() - start));         
        } catch (Exception e) {
            queue = Push.queue(certPath, certPass, isProd, numThreads);
            throw e;
        }
    }

What is the expected output? What do you see instead?
Expect to see something like 
[2013-02-13 16:19:04] INFO  (APNSServiceImpl.java:94) APNS Request received: 
{"apnsMsg":"Store 37\u0027s (SAN ANTONIO) status is now good due to Unix server 
ping being available","badge":1,"locAction":"view stores"} at 0
[2013-02-13 16:19:04] INFO  (APNSServiceImpl.java:97) Before sending: 0
[2013-02-13 16:19:04] DEBUG (PushNotificationPayload.java:193) Adding badge [1]
[2013-02-13 16:19:04] DEBUG (PushNotificationPayload.java:205) Adding sound 
[default]
[2013-02-13 16:19:04] INFO  (APNSWSClient.java:77) About to push notifications: 
0
[2013-02-13 16:19:04] INFO  (APNSWSClient.java:82) About to create push queue: 0
[2013-02-13 16:19:04] INFO  (APNSWSClient.java:90) Starting queue: 0
[2013-02-13 16:19:04] INFO  (APNSWSClient.java:92) Queue started: 0
[2013-02-13 16:19:04] INFO  (APNSWSClient.java:98) Notifications pushed: 705 at 
0
[2013-02-13 16:19:05] INFO  (APNSServiceImpl.java:99) After sending: 93
[2013-02-13 16:19:05] INFO  (APNSServiceImpl.java:118) 
{"success":true,"errorCode":0,"serverTime":93}
[2013-02-13 16:19:05] DEBUG (AnnotationMethodHandlerAdapter.java:1002) Written 
[com.neimanmarcus.apns.domain.APNSResponse@1c8ad52] as "application/json" using 
[org.springframework.http.converter.json.MappingJacksonHttpMessageConverter@1faf
3f4]
[2013-02-13 16:19:05] DEBUG (DispatcherServlet.java:824) Null ModelAndView 
returned to DispatcherServlet with name 'dispatcherServlet': assuming 
HandlerAdapter completed request handling
[2013-02-13 16:19:05] DEBUG (FrameworkServlet.java:692) Cleared thread-bound 
request context: org.apache.catalina.connector.RequestFacade@fffa61
[2013-02-13 16:19:05] DEBUG (FrameworkServlet.java:699) Successfully completed 
request
[2013-02-13 16:19:05] DEBUG (AbstractApplicationContext.java:301) Publishing 
event in WebApplicationContext for namespace 'dispatcherServlet-servlet': 
ServletRequestHandledEvent: 
url=[/apns_server/services/apns/send/Store%2037's%20(SAN%20ANTONIO)%20status%20i
s%20now%20good%20due%20to%20Unix%20server%20ping%20being%20available/1/view%20st
ores]; client=[10.0.16.30]; method=[GET]; servlet=[dispatcherServlet]; 
session=[null]; user=[null]; time=[93ms]; status=[OK]
[2013-02-13 16:19:05] DEBUG (AbstractApplicationContext.java:301) Publishing 
event in Root WebApplicationContext: ServletRequestHandledEvent: 
url=[/apns_server/services/apns/send/Store%2037's%20(SAN%20ANTONIO)%20status%20i
s%20now%20good%20due%20to%20Unix%20server%20ping%20being%20available/1/view%20st
ores]; client=[10.0.16.30]; method=[GET]; servlet=[dispatcherServlet]; 
session=[null]; user=[null]; time=[93ms]; status=[OK]
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:538) Building Raw 
message from deviceToken and payload
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:617) Built raw 
message ID 16777294 of total length 216
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:396) Attempting to 
send notification: {"aps":{"alert":{"body":"Store 37's (SAN ANTONIO) status is 
now good due to Unix server ping being available","action-loc-key":"view 
stores"},"sound":"default","badge":1}}
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:397)   to device: 
b953718a6d52cf4de0138d624a0df25a328afcb0afec8fa95927a548f2004441
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:415) Flushing
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:417) At this point, 
the entire 216-bytes message has been streamed out successfully through the SSL 
connection
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:420) Notification 
sent on first attempt
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:538) Building Raw 
message from deviceToken and payload
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:617) Built raw 
message ID 33554511 of total length 216
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:396) Attempting to 
send notification: {"aps":{"alert":{"body":"Store 37's (SAN ANTONIO) status is 
now good due to Unix server ping being available","action-loc-key":"view 
stores"},"sound":"default","badge":1}}
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:397)   to device: 
b1db026da59fe160d3a2423e00254c2905370f745f048042c147fbcfff54ad10
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:415) Flushing
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:417) At this point, 
the entire 216-bytes message has been streamed out successfully through the SSL 
connection
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:420) Notification 
sent on first attempt
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:538) Building Raw 
message from deviceToken and payload
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:617) Built raw 
message ID 50331727 of total length 216
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:396) Attempting to 
send notification: {"aps":{"alert":{"body":"Store 37's (SAN ANTONIO) status is 
now good due to Unix server ping being available","action-loc-key":"view 
stores"},"sound":"default","badge":1}}
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:397)   to device: 
8606dabb1ba9d2e87dda0652e1311fbb30a1f5651df5319584c9c3112ac14d0c
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:415) Flushing
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:417) At this point, 
the entire 216-bytes message has been streamed out successfully through the SSL 
connection
[2013-02-13 16:19:05] DEBUG (PushNotificationManager.java:420) Notification 
sent on first attempt

But i am seeing 
[2013-02-14 10:50:34] INFO  (APNSServiceImpl.java:54) APNS Request received: 
{"apnsMsg":"request APNSSend","badge":1} at 62
[2013-02-14 10:50:34] INFO  (APNSServiceImpl.java:57) Before sending: 62
[2013-02-14 10:50:34] DEBUG (PushNotificationPayload.java:193) Adding badge [1]
[2013-02-14 10:50:34] DEBUG (PushNotificationPayload.java:205) Adding sound 
[default]
[2013-02-14 10:50:34] INFO  (APNSWSClient.java:77) About to push notifications: 
16
[2013-02-14 10:50:34] INFO  (APNSWSClient.java:82) About to create push queue: 
16
[2013-02-14 10:50:34] INFO  (APNSWSClient.java:90) Starting queue: 47
[2013-02-14 10:50:34] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:34] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:34] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:34] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:35] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:35] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:35] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:35] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:36] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:36] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:36] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:36] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:37] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:37] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:37] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:37] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:38] DEBUG (ConnectionToAppleServer.java:94) Creating 
SSLSocketFactory
[2013-02-14 10:50:38] DEBUG (ConnectionToAppleServer.java:149) Creating 
SSLSocket to gateway.sandbox.push.apple.com:2195
[2013-02-14 10:50:38] INFO  (APNSWSClient.java:92) Queue started: 4594
[2013-02-14 10:50:38] INFO  (APNSWSClient.java:98) Notifications pushed: 0 at 
4594
[2013-02-14 10:50:38] INFO  (APNSServiceImpl.java:59) After sending: 4656
[2013-02-14 10:50:38] INFO  (APNSServiceImpl.java:75) 
{"success":true,"errorCode":0,"serverTime":4656}

What version of the product are you using? On what operating system?
JavaPNS2.2 on Windows server 2008R2

Please provide any additional information below.

Original issue reported on code.google.com by stack.b...@gmail.com on 14 Feb 2013 at 4:59

GoogleCodeExporter commented 9 years ago
btw, isProd = false and numThreads = 9

Original comment by stack.b...@gmail.com on 14 Feb 2013 at 5:02

GoogleCodeExporter commented 9 years ago
I'm not sure your test is valid...  You are adding notifications to a 
multi-threaded queue, but immediately after, you look at the 
pushedNotifications list and expect the threads to be done already, but they 
most certainly would not!

If I'm missing something, please let me know.. otherwise I will close this.

Original comment by sype...@gmail.com on 1 Mar 2013 at 5:29

GoogleCodeExporter commented 9 years ago
Closing because test was invalid.

Original comment by sype...@gmail.com on 8 May 2013 at 9:25