becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

[IOS] zeroconf can't find new services after switch wifi #82

Open seanyang1984 opened 5 years ago

seanyang1984 commented 5 years ago

After switch wifi, the failure callback will be called. After that the zeroconf can't find new services.

I have tried: this.zf.watch('_http._tcp.', 'local.', (result) => { }, (ec) => { // After switch wifi, this failure callback will be called. console.log("zf error: ",ec); this.zf.reInit(); });

but it does't work

Steps to reproduce:

connect wifi1 start app switch to wifi2 4.check app

emcniece commented 5 years ago

I'm curious if the Zeroconf network adapters are being disposed of properly when running reInit from inside the watch callback. Could you share some network info in various spots (ie. inside watch and inside ec) with a plugin like https://github.com/apache/cordova-plugin-network-information ?

seanyang1984 commented 5 years ago

I remove this.zf.reInit(), and add:

  this.network.onDisconnect().subscribe( () => {
    console.info('network was disconnected :-(');
  } );

  this.network.onchange().subscribe( () => {
    console.info('network was onchange :-(');
  });
  this.network.onConnect().subscribe( () => {
    console.info('network was onConnect :-(');
  });

but it only print: zf error: – null

onDisconnect, onConnect, onchange will be called on turn on or turn off wifi