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

zeroconf.watch not working on Android 9 #88

Open
sevicbb opened this issue May 19, 2020 · 3 comments
Open

zeroconf.watch not working on Android 9 #88

sevicbb opened this issue May 19, 2020 · 3 comments

Comments

@sevicbb
Copy link

sevicbb commented May 19, 2020

zeroconf.watch('_http._tcp.', 'local.', ({ action, service }) => {
    console.log(service)
    if (action === "resolved") {
      console.log(service)
    } else if (action === "removed") {
      console.log(service)
    }
})

Same code works on iOS. It was working on Android but suddenly it stopped. Any suggestions?
Getting this error in failure callback:

Error: Attempt to invoke interface method 'boolean java.util.Enumeration.hasMoreElements()' on a null object reference

@sevicbb sevicbb changed the title Not working on Android 9 zeroconf.watch not working on Android 9 May 19, 2020
@emcniece
Copy link
Collaborator

The error line appears to be here: https://github.com/becvert/cordova-plugin-zeroconf/blob/master/src/android/net/becvert/cordova/ZeroConf.java#L555

        Enumeration<String> names = service.getPropertyNames();
        while (names.hasMoreElements()) {

I suppose the service.getPropertyNames() method is returning an unexpected result. A solution might be just to try/catch this call. We should also look at service that gets passed into jsonifyService(ServiceInfo service) too, it could be that service itself is empty and doesn't have any propertyNames to iterate. The mystery then becomes "what kind of service was returned from registrationManager.register() that is invalid?

Does Android 9 change or update app permission structures?

@SamuelMichelRiad
Copy link

SamuelMichelRiad commented May 28, 2021

Does anyone have a clue on how to resolve this? It's also not working on Android 11. Are there any alternative plugins to obtain local network devices?

@emcniece
Copy link
Collaborator

emcniece commented May 29, 2021

Yes, as per my previous comment, https://github.com/becvert/cordova-plugin-zeroconf/blob/master/src/android/net/becvert/cordova/ZeroConf.java#L555 needs error handling and investigation. Apologies, I don't have capacity to do this at the moment :(

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

3 participants