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

android.system.ErrnoException on SntpClient #119

Open
cesarnorena opened this issue Jun 3, 2019 · 8 comments
Open

android.system.ErrnoException on SntpClient #119

cesarnorena opened this issue Jun 3, 2019 · 8 comments

Comments

@cesarnorena
Copy link

cesarnorena commented Jun 3, 2019

Using the 3.4 Rx version of the lib, with initializeNtp I get this error android.system.ErrnoException sendto failed: EPERM (Operation not permitted). This happens with a lot of Android versions and device brands.

Caused by android.system.ErrnoException: sendto failed: EPERM (Operation not permitted)
       at libcore.io.Linux.sendtoBytes(Linux.java)
       at libcore.io.Linux.sendto(Linux.java:225)
       at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:304)
       at libcore.io.IoBridge.sendto(IoBridge.java:569)
       at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:124)
       at java.net.DatagramSocket.send(DatagramSocket.java:721)
       at com.instacart.library.truetime.SntpClient.doubleMillis(SntpClient.java:10)
       at com.instacart.library.truetime.SntpClient.requestTime(SntpClient.java:116)
       at com.instacart.library.truetime.TrueTime.requestTime(TrueTime.java:133)
       at com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe(TrueTimeRx.java:211)
       at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:71)
       at io.reactivex.Flowable.subscribe(Flowable.java:14805)
       at io.reactivex.Flowable.subscribe(Flowable.java:14752)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
       at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
       at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
       at java.lang.Thread.run(Thread.java:764)
@dradding
Copy link

We've been experiencing this too. Any suggestions?

@calhouncole
Copy link

Us too. Any advice would be much appreciated.

@guyromb
Copy link

guyromb commented Jun 20, 2019

Same

@LosDanieloss
Copy link

Based on stacktrace and TrueTimeRx source code it looks like Flowable created for a flatmap tries to emit onNext after chain was disposed. If that's the case you could try "sweeping it under the rug" by using RxJavaPlugins.onError
Ref. ReactiveX/RxJava#4880

@LosDanieloss
Copy link

I believe I've found the issue. Inside SntpClient.java and TrueTime.java there are methods requestTime() throws IOException which are responsible for whole connection magic. In the one from SntpClient.java you can see:

catch (Exception e) {
    TrueLog.d(TAG, "---- SNTP request failed for " + ntpHost);
    throw e;
}

After checking Android docs it turns out that ErrnoException doesn't extends IOException and that is causing the crashes because TrueTimeRx wraps call to requestTime() and only expects to catch IOExpcetions. Any other exception is pushed forward to RxJavaPlugins.onError() to be handled which by default crashes as of RxJava2.
I think changing requestTime() throws IOException to requestTime() throws Exception ( or even Throwable) should solve issue. I'd try to submit PR with this shortly.

@sixpi
Copy link

sixpi commented Jul 18, 2019

I'm not sure the requestTime() is capable of throwing ErrnoExceptions - requestTime() is calling socket.send(), which only throws IOExceptions. Sockets already catch ErrnoException and rethrow as IOException.

@LosDanieloss
Copy link

I'm afraid you are right @sixpi :( Will take a look at it once again if I found some free time. All help would be appreciated. So if you have some information don't hesitate to share

@radvansky-tomas
Copy link

Any update on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants