scottdermott / cordova-plugin-discovery

Cordova Service Discovery Plugin for Android & iOS
MIT License
31 stars 30 forks source link

Missing socket bind #16

Open yetanotherjohn opened 5 years ago

yetanotherjohn commented 5 years ago

Known Android behavior: if connected WiFi doesn't have internet then network traffic is sent to a connection that does (cellular).

Issue: This plugin hangs if connected to a WiFi network that Android decided doesn't have internet.

Solution:

  1. Bind the multicast socket to a ConnectionManager.TYPE_WIFI network device.
  2. Add a break statement to the while(true) {} loop in the search function.

I have edited the plugin locally to make it work for me. I don't have the capacity to do rigorous platform testing. I'll share the file if there is interest.

bdirito commented 5 years ago

Could you provide your changes?

NBroomfield commented 2 years ago

@yetanotherjohn I'd be very interested in these changes too, my Ionic app keeps crashing, I'm guessing it's probably the same issue.

yetanotherjohn commented 2 years ago

I did not maintain the change set listed above. Given no interest was expressed for a year, and only then again 3.5 years...

The only crash I experienced with this plugin on Android was due to the one while (true) {} loop. It is easy to find and write a break statement for even without prior Java knowledge. In my experience, any other crash would be integrator's error.

For what it's worth, in my experience the iOS portion of this plugin has never had a crashing, network connectivity, or packet loss issue. It's a good litmus test for your work.

Due to problems with the Android network stack and changes to their API over time I re-wrote the entire Android portion of the SSDP plugin from scratch. I am not at liberty to share. As of a year ago, it seemed to be just a fact that Android will drop packets, never getting them to the Java plugin. This was observed over multiple vendors and hardware generations using packet sniffers and automating test runs. It appears to be an Android issue and my attempts to address it with them were flatly ignored.

Good luck.