Closed GoogleCodeExporter closed 8 years ago
... and using javapns v2.2
Original comment by mooner...@gmail.com
on 29 Feb 2012 at 1:19
... and previously I was getting out of memory errors. Those errors have been
replaced with the socket closed error above. Wondering if they were related I
rebuilt the AWS instance since posting the ticket. A production push of 147,457
tokens were all sent successfully in 231 seconds. If the pattern repeats then
I would expect that after one or two more sends the error will return. I then
will have to rebuild or restart. It will work a couple times, then repeat. Hope
that helps.
Original comment by mooner...@gmail.com
on 29 Feb 2012 at 2:09
... that didn't take long. The system one minute after posting my last message
sent out another 147K messages but it failed due to the same error above.
Rebuilding AWS Beanstalk again. Let's see if the pattern continues.
Original comment by mooner...@gmail.com
on 29 Feb 2012 at 2:12
Hi Mooner,
From the look of that stacktrace I'd say that the problem isn't with JavaPNS,
it's with the S3 connection -- it's coming out of the call to reader.readline().
I haven't worked with the Amazon API; but my recommendation would be to read
the entire csv file into memory in one hit, then process its contents.
Cheers,
Brian
Original comment by tho...@gmail.com
on 29 Feb 2012 at 3:13
Brian you might be onto something there. I have updated the code to put the
file into an ArrayList var. Once that's complete it now loops over the
ArrrayList and feeds the push queue. I will get results from this approach in
about 12 hours. I will update the ticket with the code if successful or more
details if it fails. Thanks much.
Original comment by mooner...@gmail.com
on 29 Feb 2012 at 4:01
Indeed, JavaPNS is not involved in the error you documented (it isn't even in
the stack traces you provided). It might take a long time to process all your
notifications (you have a lot of them), and that could be why your server
appears to encounter a timeout of some sort.
Unless JavaPNS appears in your stack traces, I think we could close this issue
as unrelated to JavaPNS...
Original comment by sype...@gmail.com
on 29 Feb 2012 at 3:30
Happy to report been pushing notifications all day. Except for one connection
failed, which I will assume is a AWS availability hiccup, we've been error
free. Thank you again for pointing out way to the solution.
Below is the working code for anyone who may benefit from it:
AWSCredentials myCredentials = new BasicAWSCredentials("", "");
Boolean bDev = (environment.equals("PROD")) ? false : true;
String certPass = (bDev) ? "" : "";
String certPath = (bDev) ? "Certificates-DEV.p12" : "Certificates-PROD.p12";
int threads = 30;
StringTokenizer st = null;
String token = null;
String badge = null;
String sound = null;
AmazonS3 s3Client = new AmazonS3Client(myCredentials);
GetObjectRequest getObjectRequest = new GetObjectRequest("iAPNS", noun+".csv");
S3Object s3Object = s3Client.getObject(getObjectRequest);
// GET TOKENS FROM FILE INTO VAR
int n = 0;
final class Token
{
String tokenID;
String badge;
String sound;
}
ArrayList<Token> TokenList = new ArrayList<Token>();
InputStreamReader fileSent = new InputStreamReader(s3Object.getObjectContent());
BufferedReader reader = new BufferedReader(fileSent);
String line = reader.readLine();
while ( line != null )
{
if (line.trim().equals("")) break; // continue creates a loop
st = new StringTokenizer(line, ",");
while(st.hasMoreTokens())
{
Token t = new Token();
t.tokenID = st.nextToken();
t.badge = st.nextToken();
t.sound = st.nextToken();
TokenList.add(t);
}
n++;
line = reader.readLine();
}
out.println("TokenList: " + n);
reader.close();
fileSent.close();
/* Javapns QUEUE */
PushQueue queue = Push.queue(getClass().getClassLoader().getResource(certPath).getPath(), certPass, !bDev, threads);
queue.start();
for (Token t : TokenList)
{
queue.add(PushNotificationPayload.combined(message, Integer.parseInt(t.badge), (t.sound.equals("q.wav"))?null:t.sound), t.tokenID);
}
queue.clearPushedNotifications();
out.println("Queue Sent");
}
Thank you.
Original comment by mooner...@gmail.com
on 1 Mar 2012 at 12:15
Thank you! Closing issue..
Original comment by sype...@gmail.com
on 2 Mar 2012 at 2:20
Original issue reported on code.google.com by
mooner...@gmail.com
on 29 Feb 2012 at 1:15