okhttp icon indicating copy to clipboard operation
okhttp copied to clipboard

Request URL replaced

Open justozz opened this issue 11 years ago • 2 comments

I'm making a call using retrofit 2.0 (works over okhttp) (using wi-fi). I'm using base url, in example, "http://someapi.com", using annotation @POST("/api/somemethod"), then call using "call.execute()". I've got a timeoutexception and it shows me "can't connect to http://someapi.com/[IPv6 address]" (in example http://someapi.com/2001:db8:1234:0000:0000:0000:0000:0000. why didn't it calls "http://someapi.com/api/somemethod"?

P.S. All works using 3G or LTE connection

P.S. Thread on retrofit-issues: https://github.com/square/retrofit/issues/1204

justozz avatar Nov 21 '15 23:11 justozz

In your original report, you said can't connect to http://someapi.com/[IPv6 address]. My guess is that you mistyped the error, which probably said can't connect to someapi.com/[IPv6 address] without the http:// prefix. In this case its a simple issue of an unreachable host.

swankjesse avatar Nov 22 '15 01:11 swankjesse

I have recently encountered the same issue (On okhttp v3.5.0). I requested to the original URL, but the request returns a timeout error with the original URL with IPv6 appended at the end.

However, this only happened recently (assuming due to the recent support for IPv6 from the mobile operator), and only on some networks (those that don't support IPv6 do not face this problem).

Below are some observations:

  • If DNS supports both v4 and v6, and device supports v6, then v6 will be preferred
  • After the first failed request, it seems Okhttp caches the DNS records, so subsequent requests are made to v4
  • If DNS only resolves A records, this problem disappears

It seems this may be a configuration issue on the server side, and can be solved by fixing server configurations to fully support IPv6.

Just wanted to leave this here in case others face the same issue.

pawitk avatar Jan 18 '18 06:01 pawitk