Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

onServiceLost producing NullPointerException #24

Open
paddykily opened this issue Oct 23, 2017 · 5 comments
Open

onServiceLost producing NullPointerException #24

paddykily opened this issue Oct 23, 2017 · 5 comments

Comments

@paddykily
Copy link

paddykily commented Oct 23, 2017

I have the below code in a background service.

I also tried JmDNSDriver but thats results in the following error
W/art: Failed to open zip archive '/system/framework/qcom.fmradio.jar': I/O Error

val rxBonjour = RxBonjour.Builder()
                .platform(AndroidPlatform.create(this))
                .driver(NsdManagerDriver.create(this))
                .create()

val nsdDisposable = rxBonjour.newDiscovery("_octoprint._tcp")
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(
        { event ->
            when(event) {
                is BonjourEvent.Added -> println("Resolved Service: ${event.service}")
                is BonjourEvent.Removed -> println("Lost Service: ${event.service}")
            }
        },
        { error -> println("Error during Discovery: ${error.message}") }
    )
com.robo3d E/AndroidRuntime: FATAL EXCEPTION: NsdManager
                                                            Process: com.robo3d, PID: 10842
                                                            kotlin.KotlinNullPointerException
                                                                at de.mannodermaus.rxbonjour.BonjourService.<init>(Models.kt:27)
                                                                at de.mannodermaus.rxbonjour.drivers.nsdmanager.ExtensionsKt.toLibraryModel(Extensions.kt:36)
                                                                at de.mannodermaus.rxbonjour.drivers.nsdmanager.NsdManagerDiscoveryEngine$NsdDiscoveryListener.onServiceLost(NsdManagerDiscoveryEngine.kt:61)
                                                                at android.net.nsd.NsdManager$ServiceHandler.handleMessage(NsdManager.java:336)
                                                                at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                at android.os.Looper.loop(Looper.java:148)
                                                                at android.os.HandlerThread.run(HandlerThread.java:61)
@mannodermaus
Copy link
Owner

Thanks for reporting! The only fields expected to be non-null by BonjourService are the service name, type & port. I suspected that this information has to always be there even when a service is lost, but I guess it doesn't. Is this issue reproducible to you? If so, could you place a breakpoint in NsdManagerDiscoveryEngine#L61, just before the call to toLibraryModel() is made? If I can have a look at the properties of that service object, we might be able to figure out which info may not be available to NsdManager at that time.

@Kutashov
Copy link

Good day! I have the same issue.
Here is stacktrace for NsdManagerDiscoveryEngine#L61:
name: SampleName, type: _http._tcp., host: null, port: 0

@mannodermaus
Copy link
Owner

Thanks for the insight! It probably comes down to the host address of a "lost" Service object not being available. I will examine and push a fix to the next RC shortly.

@Kutashov
Copy link

Thank you for this solution!
We can just use JmDNS driver for now. However, this driver returns two addresses for me:
BonjourService(type=_workstation._tcp.local., name=GoZeroconf, v4Host=/192.168.56.1
BonjourService(type=_workstation._tcp.local., name=GoZeroconf, v4Host=/192.168.1.68
First one is virtualbox adapter. And I have no idea how to make it go without deleting VB or moving to another machine.
BTW, it takes some time for the server to be visible in BonjourService. Possibly, because there are no dns entries in a router dns table. And I suppose, we are not capable to affect it.

@SergeyBurlaka
Copy link

SergeyBurlaka commented Feb 27, 2018

Have the same isssue with NsdManagerDriver. When use NsdManagerDriver my app just always crashes. There is solution?

@mannodermaus mannodermaus added this to the 2.0.0 milestone Feb 27, 2018
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