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.

Bug: HTTP/2 may send duplicate request on Android devices.

See original GitHub issue

We have an app on both Android and iOS, and the Android using okhttp/3.6. We tried to start http/2 support on our api server which the apps connected to, Nginx.

Everything was ok, most requests have used http/2, but something wired happend: in the nginx access_log, I found some requests with HUGE request_time, which could be more than 900s or 1000s, all these requests returned http_status_408.

And when I checked on these users(or devices), all these requests sent after users stopping using the app, and at most time these requests are duplicated.

I cannot reproduce this on my own devices, or any test devices in our company. But this should be a bug because at the same time, iOS client was working fine with http/2.

here is the wired access_log: we can find that the user stopped using app at 21:50:20, but sent more requests, after 950 seconds, the nginx log these requests at 22:01:27.

Time 	        request_time  	response_time  	http2  	status  	request  
April 25th 2017, 22:23:25.000	0.021	0.021	h2	200	/messenger/v2/conversations/unread
April 25th 2017, 22:01:27.000	956.083	0.022	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	952.644	0.081	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	940.531	0.019	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	936.136	0.01	h2	408	/v1.1/upgrade/check
April 25th 2017, 22:01:27.000	942.604	0.019	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	945.977	0.023	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	952.787	0.001	h2	408	/search/v3/config/tabs
April 25th 2017, 22:01:27.000	942.729	0.024	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	960.572	0.021	h2	408	/training/v2/running/facade/config?type=3x
April 25th 2017, 22:01:27.000	936.136	0.017	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	950.519	0.033	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	946.369	0.017	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 22:01:27.000	956.083	0.023	h2	408	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 21:50:20.000	0.001	0.001	h2	200	/v1.1/log/client?format=json&priority=normal
April 25th 2017, 21:45:28.000	0.004	0.004		200	/config/v2/basic
April 25th 2017, 21:45:21.000	0.022	0.022	h2	200	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 21:45:21.000	0.012	0.012	h2	200	/messenger/v2/conversations/unread
April 25th 2017, 21:45:21.000	0.019	0.019	h2	200	/search/v3/global?keyword=%E5%A4%A7%E8%85%BF&trainer_gender=f&limit=20
April 25th 2017, 21:45:20.000	0.008	0.008	h2	200	/messenger/v2/conversations/unread
April 25th 2017, 21:45:20.000	0.071	0.071	h2	200	/account/v2/dashboard
April 25th 2017, 21:45:20.000	0.017	0.017	h2	200	/training/v2/event/outdoor
April 25th 2017, 21:45:20.000	0.003	0.003		204	/v1.1/ads/splash?type=android
April 25th 2017, 21:45:20.000	0.015	0.015	h2	200	/social/v2/rankinglist/brief?date=20170425
April 25th 2017, 21:45:20.000	0.009	0.009	h2	200	/v1.1/home/dashboard/statistics

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
pacuumcommented, Nov 16, 2018

I am also having the same issue with my react-native Android app which uses okhttp 3.8.1 when talking to nginx + HTTP/2. In our case with probability less than 0.1% it sends multiple requests to server. When it happens, we see 128 multiple requests in our access log within a second. The number is always 128 because our nginx and HTTP/2 rejects concurrent requests more than 128.

However, at the same time, we see a gigantic number of logs like below in our nginx error log. In a worse case, it records a million of lines of this error line from the same IP within a few minutes. I’m afraid it means user sends a very large number of requests.

2018/11/15 07:06:04 [info] 8638#0: *1049430794 concurrent streams exceeded 128 while processing HTTP/2 connection, client: XX.XX.XX.XX, server: 0.0.0.0:443
2018/11/15 07:06:04 [info] 8638#0: *1049430794 concurrent streams exceeded 128 while processing HTTP/2 connection, client: XX.XX.XX.XX, server: 0.0.0.0:443
2018/11/15 07:06:04 [info] 8638#0: *1049430794 concurrent streams exceeded 128 while processing HTTP/2 connection, client: XX.XX.XX.XX, server: 0.0.0.0:443

By disabling HTTP/2, the problem disappeared. The strange thing is it only happens with POST and DELETE, though our app sends more GET and OPTIONS requests than POST and DELETE. It seems more likely to happen with slow APIs (image uploading for example).

1reaction
swankjessecommented, Nov 16, 2018

@pacuum oooh, that’s helpful for debugging this. Perhaps we’re timing out client side and retrying on the same HTTP/2 connection?

Read more comments on GitHub >

github_iconTop Results From Across the Web

duplicate requests from HttpClient - android - Stack Overflow
1 on android... I make a POST request with a header set that is the current millis... I see that request hit the...
Read more >
Capture and read bug reports - Android Developers
A bug report contains device logs, stack traces, and other diagnostic information to help you find and fix bugs in your app.
Read more >
Known issues with Android Studio and Android Gradle Plugin
This update causes an underlying behavior change related to signing keys. To work around this issue, enter the same password for both the...
Read more >
ANRs - Android Developers
You can capture a bug report from a physical device by using either the Take bug report developer option on the device, or...
Read more >
Behavior changes: Apps targeting Android 12
On devices that run Android 12 or higher, users can request approximate location ... meaning they require a secure context and should be...
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