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

Fatal Exception: io.reactivex.exceptions.UndeliverableException: java.io.IOException: Operation not permitted #63

Closed
IonutNegru87 opened this issue Sep 10, 2017 · 14 comments
Labels
awaiting feedback Awaiting feedback before resolving/closing

Comments

@IonutNegru87
Copy link

IonutNegru87 commented Sep 10, 2017

Recently I started receiving the following crash:

Fatal Exception: io.reactivex.exceptions.UndeliverableException: java.io.IOException: Operation not permitted
       at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:349)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.innerError(FlowableFlatMap.java:604)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$InnerSubscriber.onError(FlowableFlatMap.java:665)
       at io.reactivex.internal.operators.flowable.FlowableRetryPredicate$RepeatSubscriber.onError(FlowableRetryPredicate.java:81)
       at io.reactivex.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onError(FlowableDoOnEach.java:110)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.onError(FlowableSubscribeOn.java:102)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.onError(FlowableCreate.java:268)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.drain(FlowableCreate.java:510)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.onError(FlowableCreate.java:461)
       at com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe(TrueTimeRx.java:201)
       at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:72)
       at io.reactivex.Flowable.subscribe(Flowable.java:12986)
       at io.reactivex.Flowable.subscribe(Flowable.java:12932)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
       at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
       at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:761)
Caused by java.io.IOException: Operation not permitted
       at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java)
       at java.net.DatagramSocket.send(DatagramSocket.java:691)
       at com.instacart.library.truetime.SntpClient.requestTime(SntpClient.java:114)
       at com.instacart.library.truetime.TrueTime.requestTime(TrueTime.java:122)
       at com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe(TrueTimeRx.java:197)
       at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:72)
       at io.reactivex.Flowable.subscribe(Flowable.java:12986)
       at io.reactivex.Flowable.subscribe(Flowable.java:12932)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
       at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
       at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:761)

I've recently updated the initialization to TrueTimeRx. Before this, I haven't received any crashes.
Can you help me solve this?

This is my initialization:

private void initTime() {
    TrueTimeRx.build()
              .initializeRx("time.google.com")
              .subscribeOn(Schedulers.io())
              .subscribe(date -> Timber.v("initTime(): TrueTime was initialized and we have a time: " + date),
                  Throwable::printStackTrace);
  }

Method which I call in onCreate() method of my project Application class.

@IonutNegru87
Copy link
Author

Also, I was wondering if Completable isn't a better choice for the initialization process?

@kaushikgopal
Copy link
Collaborator

you sure this is not a permissions issue? Operation not permitted generally points towards that. but not sure if it's some weird network/ssl issue. are you consistently seeing this crash? i.e. is it reproducible. if not, difficult to tell what the problem is, without more info.

wrt Completable (the init method also needs to emit the result, which is why i chose a regular Observable. Completable doesn't emit an onNext result. (also please open a different issue for this, if you want follow up questions)

✌️

@AndrewBedscastle
Copy link

AndrewBedscastle commented Oct 16, 2017

Same here:
Initilization

                        .withSharedPreferences(context)
                        .initializeRx("time.apple.com")
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(
                                date ->
                                {
                                    MyLogger.i(TAG, "True time date is available");

                                    // .... subscriber code
                                       ...
                                      ...

                                    successfullyReceivedDate = true;                                   

                                },
                                throwable ->
                                        MyLogger.e(TAG, "Error while trying to get NTP time", throwable));

I call it in onCreate() of my application class

The Google Play Console is full of crashes like this

io.reactivex.exceptions.UndeliverableException: 
  at io.reactivex.plugins.RxJavaPlugins.onError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.innerError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableFlatMap$InnerSubscriber.onError (Unknown Source)
  at io.reactivex.internal.subscribers.BasicFuseableSubscriber.onError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableToList$ToListSubscriber.onError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.checkTerminate (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.drainLoop (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.drain (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.innerError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableFlatMap$InnerSubscriber.onError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableRetryPredicate$RepeatSubscriber.onError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.onError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.error (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.drain (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.tryOnError (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.onError (Unknown Source)
  at com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual (Unknown Source)
  at io.reactivex.Flowable.subscribe (Unknown Source)
  at io.reactivex.Flowable.subscribe (Unknown Source)
  at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run (Unknown Source)
  at io.reactivex.internal.schedulers.ScheduledRunnable.run (Unknown Source)
  at io.reactivex.internal.schedulers.ScheduledRunnable.call (Unknown Source)
  at java.util.concurrent.FutureTask.run (FutureTask.java:237)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:272)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
  at java.lang.Thread.run (Thread.java:762)
Caused by: java.io.IOException: 
  at java.net.PlainDatagramSocketImpl.send (Native Method)
  at java.net.DatagramSocket.send (DatagramSocket.java:694)
  at com.instacart.library.truetime.SntpClient.requestTime (Unknown Source)
  at com.instacart.library.truetime.TrueTime.requestTime (Unknown Source)

I did not get any error reports from my users that the app is really crashing, but this is really really strange...
Do you know why this happens?
How can it be avoided?

Would that help?
ReactiveX/RxJava#4863

@AndrewBedscastle
Copy link

I think you should really use this one:
http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/FlowableEmitter.html#tryOnError-java.lang.Throwable-
More details:
ReactiveX/RxJava#4880

@TonyTangAndroid
Copy link
Contributor

I am also running into this issue. And it has a lot of reports from Crashlytics. But somehow I could not manage to reproduce it on my own device.

@lemberh
Copy link

lemberh commented Dec 13, 2017

Same problem in my App.
The problem is that despite I have onError callback everywhere where I subscribe to the app the app is crashing,
Seems the reason is in the producer (Flowable) implementation
This stackoverflow answer describes this issue https://stackoverflow.com/a/43525858/1307690
Looks like I had already disposed my subscription but SMTP client is still waiting for response and then crashes, but at that time there is nobody to handle this exception as I already had disposed my subscription.

Fatal Exception: io.reactivex.exceptions.UndeliverableException: java.io.IOException: Operation not permitted
       at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:349)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.innerError(FlowableFlatMap.java:604)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$InnerSubscriber.onError(FlowableFlatMap.java:665)
       at io.reactivex.internal.subscribers.BasicFuseableSubscriber.onError(BasicFuseableSubscriber.java:101)
       at io.reactivex.internal.operators.flowable.FlowableToList$ToListSubscriber.onError(FlowableToList.java:81)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.checkTerminate(FlowableFlatMap.java:563)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.drainLoop(FlowableFlatMap.java:374)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.drain(FlowableFlatMap.java:366)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.innerError(FlowableFlatMap.java:602)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$InnerSubscriber.onError(FlowableFlatMap.java:665)
       at io.reactivex.internal.operators.flowable.FlowableRetryPredicate$RepeatSubscriber.onError(FlowableRetryPredicate.java:81)
       at io.reactivex.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onError(FlowableDoOnEach.java:111)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.onError(FlowableSubscribeOn.java:102)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.error(FlowableCreate.java:288)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.drain(FlowableCreate.java:531)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.tryOnError(FlowableCreate.java:481)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.onError(FlowableCreate.java:270)
       at com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe(TrueTimeRx.java:209)
       at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:72)
       at io.reactivex.Flowable.subscribe(Flowable.java:12995)
       at io.reactivex.Flowable.subscribe(Flowable.java:12941)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
       at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
       at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:761)
Caused by java.io.IOException: Operation not permitted
       at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java)
       at java.net.DatagramSocket.send(DatagramSocket.java:696)
       at com.instacart.library.truetime.SntpClient.requestTime(SntpClient.java:116)
       at com.instacart.library.truetime.TrueTime.requestTime(TrueTime.java:122)
       at com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe(TrueTimeRx.java:205)
       at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:72)
       at io.reactivex.Flowable.subscribe(Flowable.java:12995)
       at io.reactivex.Flowable.subscribe(Flowable.java:12941)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
       at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
       at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run(Thread.java:761)

@guillerial
Copy link

guillerial commented Feb 23, 2018

Hello, has anyone found a solution to this issue?

Same problem here:

Fatal Exception: io.reactivex.exceptions.UndeliverableException: java.io.IOException: sendto failed: EPERM (Operation not permitted)
       at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:349)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$MergeSubscriber.innerError(FlowableFlatMap.java:604)
       at io.reactivex.internal.operators.flowable.FlowableFlatMap$InnerSubscriber.onError(FlowableFlatMap.java:665)
       at io.reactivex.internal.operators.flowable.FlowableRetryPredicate$RepeatSubscriber.onError(FlowableRetryPredicate.java:81)
       at io.reactivex.internal.operators.flowable.FlowableDoOnEach$DoOnEachSubscriber.onError(FlowableDoOnEach.java:110)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.onError(FlowableSubscribeOn.java:102)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BaseEmitter.onError(FlowableCreate.java:268)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.drain(FlowableCreate.java:510)
       at io.reactivex.internal.operators.flowable.FlowableCreate$BufferAsyncEmitter.onError(FlowableCreate.java:461)
       at com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe(TrueTimeRx.java:201)
       at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:72)
       at io.reactivex.Flowable.subscribe(Flowable.java:12986)
       at io.reactivex.Flowable.subscribe(Flowable.java:12932)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
       at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
       at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
       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)
Caused by java.io.IOException: sendto failed: EPERM (Operation not permitted)
       at libcore.io.IoBridge.maybeThrowAfterSendto(IoBridge.java:603)
       at libcore.io.IoBridge.sendto(IoBridge.java:571)
       at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:124)
       at java.net.DatagramSocket.send(DatagramSocket.java:721)
       at com.instacart.library.truetime.SntpClient.requestTime(SntpClient.java:114)
       at com.instacart.library.truetime.TrueTime.requestTime(TrueTime.java:122)
       at com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe(TrueTimeRx.java:197)
       at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:72)
       at io.reactivex.Flowable.subscribe(Flowable.java:12986)
       at io.reactivex.Flowable.subscribe(Flowable.java:12932)
       at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
       at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61)
       at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52)
       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)

@kaushikgopal
Copy link
Collaborator

dang @AndrewBedscastle ! that's a good catch.

🤔 i'm really tempted to use the new RxJava tryOnError api. The big caveat is it's currently marked experimental. for more context:

🤔 after thinking about this a little more, my current thinking:

Having seen how the api changes progress with Rx, i'm inclined to actually start using this. If for some reason, this api is removed or modified, we can go back to manually checking if emitter.isDisposed and throwing error in that circumstance. Granted, that would then open us up to the potential race condition mentioned in the first link. But that's a bridge I feel we can cross, when we get there.

stay tuned for a PR that should help with this

@kaushikgopal kaushikgopal added the wip A current PR or fix will address this in the future label May 29, 2018
@kaushikgopal
Copy link
Collaborator

jk, there's already a PR #70 that @AndrewBedscastle has up

@kaushikgopal
Copy link
Collaborator

master should have the required fixes now. If you're eager to take this before it hits 3.4 try:

implementation com.github.instacart.truetime-android:library-extension-rx:09087b6a6e

@kaushikgopal kaushikgopal added awaiting feedback Awaiting feedback before resolving/closing and removed wip A current PR or fix will address this in the future labels May 29, 2018
@yarkh
Copy link

yarkh commented Sep 4, 2018

@kaushikgopal when will 3.4 be released? Will this fix be included?
I get bunch of errors for my production build from Google Play crashes:

java.io.IOException
in com.instacart.library.truetime.SntpClient.requestTime

android.system.ErrnoException
in com.instacart.library.truetime.SntpClient.requestTime

io.reactivex.exceptions.CompositeException
in com.instacart.library.truetime.TrueTimeRx$4$1$2.subscribe

com.instacart.library.truetime.InvalidNtpServerResponseException
in com.instacart.library.truetime.SntpClient.requestTime

android.system.ErrnoException
in com.instacart.library.truetime.SntpClient.requestTime

@kaushikgopal
Copy link
Collaborator

@yarkh 3.4 is released!

@anandwana001
Copy link

I am getting error in my production app

Fatal Exception: io.reactivex.exceptions.UndeliverableException
java.io.IOException: Operation not permitted

Dependency

implementation 'com.github.instacart.truetime-android:library-extension-rx:3.4'

Implementation

val disposable = TrueTimeRx.build()
                .withConnectionTimeout(31428)
                .withLoggingEnabled(true)
                .initializeRx("17.253.84.251")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeWith(object : DisposableSingleObserver<Date>() {
                    override fun onSuccess(date: Date) {
                        Log.d("TrueTimeTag", "Success initialized TrueTime :" + date.toString())
                    }

                    override fun onError(e: Throwable) {
                        Log.e("TrueTimeTag", "something went wrong when trying to initializeRx TrueTime", e)
                    }
                })

used a specific ip address as time.google.com and time.apple.com not even giving the response, big delay.

Help me here.

@apexkid
Copy link

apexkid commented May 21, 2020

I am seeing the same error on crashlytics for around 20% of my users. I am using 3.4 version. How to fix this? This is a major issue which should be addressed. Else it will make the library unusable for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback Awaiting feedback before resolving/closing
Projects
None yet
Development

No branches or pull requests

9 participants