apns-http2: Getting Exception while running with OKhttp3 + No notification

Exception in thread "main" java.io.IOException: unexpected end of stream on okhttp3.Address@5106fe42
    at okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:199)
    at okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:125)
    at okhttp3.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:723)
    at okhttp3.internal.http.HttpEngine.access$200(HttpEngine.java:81)
    at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:708)
    at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
    at okhttp3.RealCall.getResponse(RealCall.java:241)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
    at okhttp3.RealCall.execute(RealCall.java:57)
    at com.clevertap.jetty.apns.http2.clients.SyncOkHttpApnsClient.main(SyncOkHttpApnsClient.java:229)
Caused by: java.io.EOFException: \n not found: size=176 content=0000180400000000000001000010000003000001c4000500004000000600001f...
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:201)
    at okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:184)
    ... 10 more

We tried it with builder pattern you had provided, also we tried to use directly the constructor itself and then client private from SyncOkHttpApnsClient.java. But both produced same results.

final ApnsClient apnsClient = new ApnsClientBuilder()
        .withProductionGateway()
        .inSynchronousMode()
        .withCertificate(cert)
        .withPassword("pass")
        .withOkHttp3()
        .build();
Notification notification = new  Notification.Builder(token).alertBody("Example!015").sound("default").build();
NotificationResponse response = apnsClient.push(notification);

We also had same exception when we tried to use OkHttp. Any kind of help will be much appreciated.

Request request = new Request.Builder()
              .url("https://api.push.apple.com:443/3/device/{token}")
              .post(body).header("apns-priority","10")
              .build();
          Response response = apnsClient.client.newCall(request).execute();
          System.out.println(response);

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

Indeed, I have to learn to read “readme” files from top to bottom, but not just look at the code samples 😃 Interesting though that in my case exception was indicating the same issue as described by person who initiated this ticket:

...
Caused by: java.io.EOFException: \n not found: size=176
...

I believe the person has felt into the same trap as me.