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

Allow changing SNTP client timeout #1540

Closed
jrocharodrigues opened this issue Jul 11, 2024 · 2 comments
Closed

Allow changing SNTP client timeout #1540

jrocharodrigues opened this issue Jul 11, 2024 · 2 comments

Comments

@jrocharodrigues
Copy link

[REQUIRED] Use case description

We started seeing some high video start times (~10 seconds) in our live stream app. After some investigation we found out the problem was that due to some problem in their network, the request to the SNTP server to resolve the time offset was timing out, and this exception was thrown:

Failed to resolve time offset.
  java.net.SocketTimeoutException: Poll timed out
      at libcore.io.IoBridge.poll(IoBridge.java:682)
      at java.net.PlainDatagramSocketImpl.doRecv(PlainDatagramSocketImpl.java:150)
      at java.net.PlainDatagramSocketImpl.receive0(PlainDatagramSocketImpl.java:141)
      at java.net.AbstractPlainDatagramSocketImpl.receive(AbstractPlainDatagramSocketImpl.java:164)
      at java.net.DatagramSocket.receive(DatagramSocket.java:847)
      at androidx.media3.exoplayer.util.SntpClient.loadNtpTimeOffsetMs(SntpClient.java:185)
      at androidx.media3.exoplayer.util.SntpClient.access$400(SntpClient.java:41)
      at androidx.media3.exoplayer.util.SntpClient$NtpTimeLoadable.load(SntpClient.java:300)
      at androidx.media3.exoplayer.upstream.Loader$LoadTask.run(Loader.java:421)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
      at java.lang.Thread.run(Thread.java:919)

After some digging, we found out the problem was due to the client could not reach the sntp server (time.android.com) with IPv6.
Changing the server to one without IPv6, or disabling IPv6 on the client network would solve the problem.

Proposed solution

It would be great if exoplayer allowed to change the timeout of the sntp request, because the default, 10 seconds, seems to high for a non critical request.

It would also be nice if the exoplayer SNTP client would follow the protocol and attempt the alternative ipAddresses in case of failure, which would also solve the problem we we're having due to IPv6 connectivity problems.

Thanks in advance for your support
Best regards

@rohitjoins rohitjoins self-assigned this Jul 12, 2024
copybara-service bot pushed a commit that referenced this issue Jul 15, 2024
Added a method to set the timeout for the SNTP request.

Also changed the default timeout to 5s instead of 10s as it seemed quite high.

Issue: #1540
PiperOrigin-RevId: 652566008
copybara-service bot pushed a commit that referenced this issue Jul 16, 2024
Changed the default timeout for SNTP requests to 1 second.

Issue: #1540
PiperOrigin-RevId: 652897579
@rohitjoins
Copy link
Contributor

Hi @jrocharodrigues,

We have added changes to allow changing SNTP client timeout and retrying alternative addresses. Thank you for reporting this issue and feel free to reopen this issue in case you have any more questions / suggestions.

@jrocharodrigues
Copy link
Author

Hi @rohitjoins ,

Thanks for the fast response and fix.

Best regards

@androidx androidx locked and limited conversation to collaborators Sep 15, 2024
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

2 participants