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

Support retrying network errors indefinitely #7309

Closed
DorisGM opened this issue Apr 29, 2020 · 4 comments
Closed

Support retrying network errors indefinitely #7309

DorisGM opened this issue Apr 29, 2020 · 4 comments
Assignees

Comments

@DorisGM
Copy link

DorisGM commented Apr 29, 2020

[REQUIRED] Issue description

When I played a video for a long time, maybe the network isn't good.so throw HttpDataSource$HttpDataSourceException: java.net.SocketTimeoutException: timeout when invoke read method. I want to catch this error at onPlayerError and to retry play .But I found i can't receive this error at this method. And after throw this error, exoplayer don't play anymore ,freeze at last frame.

[REQUIRED] Reproduction steps

SocketTimeoutException: timeout when read can't catch up by onPlayerError.

[REQUIRED] Link to test content

sorry, the content link is provisional.

[REQUIRED] A full bug report captured from the device

EventLogger: internalError [eventTime=6411.38, mediaPos=0.02, window=0, period=0, loadError
04-27 18:54:23.808 7101 7101 E EventLogger: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: java.net.SocketTimeoutException: timeout
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.read(DefaultHttpDataSource.java:359)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.upstream.DefaultDataSource.read(DefaultDataSource.java:182)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.upstream.StatsDataSource.read(StatsDataSource.java:91)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.extractor.DefaultExtractorInput.readFromDataSource(DefaultExtractorInput.java:287)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.extractor.DefaultExtractorInput.read(DefaultExtractorInput.java:62)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.extractor.ts.TsExtractor.fillBufferWithAtLeastOnePacket(TsExtractor.java:385)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.extractor.ts.TsExtractor.read(TsExtractor.java:275)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:982)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
04-27 18:54:23.808 7101 7101 E EventLogger: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
04-27 18:54:23.808 7101 7101 E EventLogger: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
04-27 18:54:23.808 7101 7101 E EventLogger: at java.lang.Thread.run(Thread.java:761)
04-27 18:54:23.808 7101 7101 E EventLogger: Caused by: java.net.SocketTimeoutException: timeout
04-27 18:54:23.808 7101 7101 E EventLogger: at com.android.okhttp.okio.Okio$3.newTimeoutException(Okio.java:212)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.android.okhttp.okio.AsyncTimeout.exit(AsyncTimeout.java:261)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:215)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.android.okhttp.okio.RealBufferedSource.read(RealBufferedSource.java:50)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.android.okhttp.internal.http.HttpConnection$UnknownLengthSource.read(HttpConnection.java:516)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.android.okhttp.okio.RealBufferedSource$1.read(RealBufferedSource.java:371)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.readInternal(DefaultHttpDataSource.java:696)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.read(DefaultHttpDataSource.java:357)
04-27 18:54:23.808 7101 7101 E EventLogger: ... 11 more
04-27 18:54:23.808 7101 7101 E EventLogger: Caused by: java.net.SocketException: Socket closed
04-27 18:54:23.808 7101 7101 E EventLogger: at java.net.SocketInputStream.socketRead0(Native Method)
04-27 18:54:23.808 7101 7101 E EventLogger: at java.net.SocketInputStream.read(SocketInputStream.java:151)
04-27 18:54:23.808 7101 7101 E EventLogger: at java.net.SocketInputStream.read(SocketInputStream.java:120)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.android.okhttp.okio.Okio$2.read(Okio.java:136)
04-27 18:54:23.808 7101 7101 E EventLogger: at com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
04-27 18:54:23.808 7101 7101 E EventLogger: ... 16 more
04-27 18:54:23.808 7101 7101 E EventLogger: ]

[REQUIRED] Version of ExoPlayer being used

the latest.

[REQUIRED] Device(s) and version(s) of Android being used

H6, Android 7.1

@DorisGM DorisGM changed the title SocketTimeoutException: timeout when read SocketTimeoutException: timeout when read can't catch up by onPlayerError Apr 29, 2020
@AquilesCanta
Copy link
Contributor

A few points:

  • "EventLogger: internalError" works because onPlayerError is being called. So I don't think it's the case that onPlayerError is not being called.
  • However, it's possible that the data source is taking some time to surface SocketException. There are two reasons for which this happens: (1) Timeouts require some time. (2) The errors are first passed through the LoadErrorHandlingPolicy to see if they should be retried. The error will not be surfaced through onPlayer error until the retries of the LoadErrorHandlingPolicy have been exhausted.

If you want to retry indefinitely when a network error occurs, you should use the LoadErrorHandlingPolicy. There's actually some material here, but I'm also working on an improvement which I will link to this issue. I'll also use this issue to track support for indefinite network issues retries.

@AquilesCanta AquilesCanta changed the title SocketTimeoutException: timeout when read can't catch up by onPlayerError Support retrying network errors indefinitely Apr 30, 2020
ojw28 pushed a commit that referenced this issue May 1, 2020
Issue: #7309
PiperOrigin-RevId: 309387483
@DorisGM DorisGM changed the title Support retrying network errors indefinitely SocketTimeoutException: timeout when read can't catch up by onPlayerError. May 4, 2020
@DorisGM DorisGM changed the title SocketTimeoutException: timeout when read can't catch up by onPlayerError. Support retrying network errors indefinitely May 4, 2020
@DorisGM
Copy link
Author

DorisGM commented May 4, 2020

Thanks for your replay. I added a log to onPlayError, but nothing prints out when EventLogger print this error. It's probably caused by the second point you said. I'll try to use LoadErrorHandlingPolicy. Let me know if there's any progress. thanks again.

ojw28 pushed a commit that referenced this issue May 5, 2020
Issue: #7309
PiperOrigin-RevId: 309749566
ojw28 pushed a commit that referenced this issue May 13, 2020
ojw28 pushed a commit that referenced this issue May 14, 2020
ojw28 pushed a commit that referenced this issue May 14, 2020
Issue:#7309
PiperOrigin-RevId: 311504497
ojw28 pushed a commit that referenced this issue May 18, 2020
@ojw28
Copy link
Contributor

ojw28 commented Jun 11, 2020

@AquilesCanta - Is there remaining work to do here?

@AquilesCanta
Copy link
Contributor

Hi @DorisGM, this is already supported in the dev branch. Please check it out and reach back if you find any issues.

Please have a look at the new LoadErrorHandlingPolicy interface. You will notice that each load error is associated to a task id. By using that id, you can keep track of all errors associated to that id. For network errors, you can use indefinite retry. For others you can implement a different retry/back off strategy.

@google google locked and limited conversation to collaborators Oct 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants