question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting Exception while running with OKhttp3 + No notification

See original GitHub issue
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);

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
darklynxcommented, Dec 2, 2016

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.

1reaction
judepereiracommented, Dec 2, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can not get response while using okHttp3 - Stack Overflow
Can not get response while using okHttp3 ; public class MainActivity extends AppCompatActivity implements View.OnClickListener ; setContentView(R.
Read more >
Crash on okhttp3 client after updating Android app to v6.3.1
Hi there, After updating to v6.3.1 in Android, the app crashes on okhttp3 client: LOCATION Cache.java line 233 in `okhttp3.
Read more >
OkHttp Android Example Tutorial - DigitalOcean
OkHttp is a third party library that was introduced by Square in 2013 for sending and receive HTTP-based network requests. OkHttp Android.
Read more >
Retrofit 2 — Simple Error Handling - Future Studio
It is working fine. Recently I have faced a problem with my android application. It is not opening in edge signal. I am...
Read more >
Recipes - OkHttp
private val client = OkHttpClient() fun run() { val request = Request. ... Download a file on a worker thread, and get called...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found