Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Treat malformed HTTP responses as connection errors #63

Merged
merged 3 commits into from
Sep 30, 2020

Conversation

gnarea
Copy link
Member

@gnarea gnarea commented Sep 30, 2020

By default, OkHTTP would throw an IOException when an illegal HTTP response is returned, which is an unexpected exception. This PR replaces that exception with java.net.ConnectException, which we catch and wrap with a PoWeb ServerConnectionException, which provides more useful information.

Before:

java.io.IOException: unexpected end of stream on http://127.0.0.1:13276/...
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:202)
        (...)
     Caused by: java.io.EOFException: \n not found: limit=0 content=…
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:348)
        (...)

Now, using relaycorp/relaynet-gateway-android@731ab77:

tech.relaycorp.poweb.ServerConnectionException: Failed to connect to http://127.0.0.1:13276/v1/parcels
(...)
Caused by: java.net.ConnectException: Failed to connect to /127.0.0.1:13276
(...)
Caused by: java.net.ConnectException: failed to connect to /127.0.0.1 (port 13276) from /127.0.0.1 (port 43068) after 10000ms: (...)
Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)

@gnarea gnarea self-assigned this Sep 30, 2020
gnarea added a commit to relaycorp/relaynet-gateway-android that referenced this pull request Sep 30, 2020
gnarea added a commit to relaycorp/relaynet-gateway-android that referenced this pull request Sep 30, 2020
@gnarea gnarea changed the title fix: Intermittent IOException when delivering parcels fix: Treat malformed HTTP responses as connection errors Sep 30, 2020
@gnarea gnarea marked this pull request as ready for review September 30, 2020 10:25
@kodiakhq kodiakhq bot merged commit ded7c40 into master Sep 30, 2020
@kodiakhq kodiakhq bot deleted the IOException-bugfix branch September 30, 2020 10:28
@github-actions
Copy link

🎉 This PR is included in version 1.5.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

gnarea added a commit to relaycorp/relaynet-gateway-android that referenced this pull request Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant