Skyost / Bonsoir

A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD.
http://bonsoir.skyost.eu/
Other
107 stars 49 forks source link

On iOS, both broadcast and discovery stop immediately after restarting #71

Closed sarbogast closed 10 months ago

sarbogast commented 10 months ago

Describe the bug In my app, I start, stop and restart both broadcast and discovery. On Android, everything works smoothly as expected. On iOS, everything works as expected the first time, but after I stop and restart either broadcast or discovery, they are immediately stopped without me calling stop() on them.

To Reproduce Steps to reproduce the behavior:

  1. Clone this repository
  2. Adapt your signing team
  3. Run the app on an iOS device
  4. Click Broadcast
  5. Click Stop broadcasting
  6. Click Broadcast again

Expected behavior If you look at the logs, the first time you start broadcasting, you can see the following series of events:

flutter: Serving at http://192.168.1.55:8080
flutter: Broadcast event : BonsoirBroadcastEventType.broadcastStarted

And then when you click "Stop broadcasting", you can see this event:

flutter: Broadcast event : BonsoirBroadcastEventType.broadcastStopped

But then when you click "Broadcast" again, you can see the following:

fflutter: Serving at http://192.168.1.55:8080
flutter: Broadcast event : BonsoirBroadcastEventType.broadcastStarted
flutter: Broadcast event : BonsoirBroadcastEventType.broadcastStopped

Why does the broadcastStopped event happen?

Smartphone (please complete the following information):

Additional context Note that the same thing happens for discovery. But it doesn't happen on Android, neither for broadcast, nor for discovery.

Skyost commented 10 months ago

Thanks for reporting ! It seems that broadcast.stop() is called somewhere. We need to figure out where and why.

EDIT : Seems to be a problem with AutoStopBonsoirAction.

Skyost commented 10 months ago

It's clearly a problem with AutoStopBonsoirAction. Using connectivity_plus on Darwin, the first result is wifi and the second is none (that's why a stop() is triggered). We'll get rid of this, as platforms should properly handle the actions interruption.

sarbogast commented 10 months ago

That's interesting. I used to use connectivity_plus to check for connectivity before even starting discovery or broadcasting, and I stopped using it because it was giving me inconsistency none connectivity sometimes.

sarbogast commented 10 months ago

And apparently it's a known issue.