RouterException: Router wasn't available exclusively

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

RouterException: Router wasn't available exclusively

DREDD112
Hi! I'm using Cling version 2.0-SNAPSHOT and on UpnpService shutdown I'm getting this exception:

AndroidRuntime﹕ FATAL EXCEPTION: Thread-2452
    java.lang.RuntimeException: Router error on shutdown: org.fourthline.cling.transport.RouterException: Router wasn't available exclusively after waiting 15000ms, lock failed: WriteLock
            at org.fourthline.cling.UpnpServiceImpl.shutdownRouter(UpnpServiceImpl.java:168)
            at org.fourthline.cling.UpnpServiceImpl$1.run(UpnpServiceImpl.java:143)
            at java.lang.Thread.run(Thread.java:856)
     Caused by: org.fourthline.cling.transport.RouterException: Router wasn't available exclusively after waiting 15000ms, lock failed: WriteLock
            at org.fourthline.cling.transport.RouterImpl.lock(RouterImpl.java:497)
            at org.fourthline.cling.transport.RouterImpl.lock(RouterImpl.java:510)
            at org.fourthline.cling.android.AndroidRouter.disable(AndroidRouter.java:104)
            at org.fourthline.cling.transport.RouterImpl.shutdown(RouterImpl.java:199)
            at org.fourthline.cling.android.AndroidRouter.shutdown(AndroidRouter.java:79)
            at org.fourthline.cling.UpnpServiceImpl.shutdownRouter(UpnpServiceImpl.java:162)
            at org.fourthline.cling.UpnpServiceImpl$1.run(UpnpServiceImpl.java:143)
            at java.lang.Thread.run(Thread.java:856)

And my app crashes instantly. Any ideas why this may be happening? What am I doing wrong? Any clues will be helpful.
I'm testing on Samsung Galaxy S4, Android 4.2.2
Reply | Threaded
Open this post in threaded view
|

Re: RouterException: Router wasn't available exclusively

Leosplan
I also came across this problem, did you find any solution?
Reply | Threaded
Open this post in threaded view
|

Re: RouterException: Router wasn't available exclusively

DREDD112
Yeah, I created a workaround, but got rid of it, when the alpha3 version came out - the bug doesn't seem to reproduce there. Just try to update you cling lib.
Reply | Threaded
Open this post in threaded view
|

Re: RouterException: Router wasn't available exclusively

Leosplan
Hi, I tried with the latest cling, it still happens though it happened very rare. What kind of workaround did you apply?
Reply | Threaded
Open this post in threaded view
|

Re: RouterException: Router wasn't available exclusively

DREDD112
Yep, happened again :( Here you go: https://github.com/4thline/cling/pull/92 
If Christian doesn't apply it, you can do it by yourself by extending your UpnpServiceImpl class and overriding the shutdownRouter() method.
Sorry, don't have time to find out reasons of this happening since the bug happens once in a blue moon, so that's all I can suggest for now.
Reply | Threaded
Open this post in threaded view
|

Re: RouterException: Router wasn't available exclusively

DREDD112
Oopsy, the link, doesn't seem to work, anyways you can find it on github in the list of pull requests.
Reply | Threaded
Open this post in threaded view
|

Re: RouterException: Router wasn't available exclusively

Christian Bauer
Administrator
It's not a bug. It means there is most likely a hanging outgoing HTTP request when the network interface disappears or Cling is shut down.

Why it hangs might have many reasons, Cling sets timeouts in HTTP client code. There are equally many ways how you can deal with this situation, for example ignore it on shutdown.

This is something people can explain who have used Cling in production, there is only so much a library can do consodering buggy subsystems.

If someone has any GENERIC solution to a GENERAL problem we can add it to Cling. Also this has been discussed exhaustively here before.

I will change the exception message explaining this better, so far nobody has even given me a reproducible scenario.
Reply | Threaded
Open this post in threaded view
|

Re: RouterException: Router wasn't available exclusively

DREDD112
I wish it wouldn't take adding two files to a project in order to suppress that exception on android, but anyways thanks for the explanation. I will have our QA team try to find a way to reproduce the issue, so I could find the generic solution, will let you know, if I have something.