balthazar / react-native-zeroconf

:satellite: Discover Zeroconf services using react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot perform two searches at the same time

xploSEoF opened this issue · comments

It would seem I cannot perform two searches at the same time with different instances of the Zeroconf class.

This is on iOS devices - I haven't been able to test on anything else.

This code:

import Zeroconf from 'react-native-zeroconf';

z1 = new Zeroconf();

z1.on('start', () => { console.debug('Zero1', 'Started'); });
z1.on('stop', () => { console.debug('Zero1', 'Stoped'); });
z1.on('found', (a) => { console.debug('Zero1', 'FOUND!', a); });
z1.on('resolved', (a) => { console.debug('Zero1', 'Resolved', a.name, a.port); });
z1.on('error', (e) => { console.warn('Zero1', 'Errored', e); });

z2 = new Zeroconf();

z2.on('start', () => { console.debug('Zero2', 'Started'); });
z2.on('stop', () => { console.debug('Zero2', 'Stoped'); });
z2.on('found', (a) => { console.debug('Zero2', 'FOUND!', a); });
z2.on('resolved', (a) => { console.debug('Zero2', 'Resolved', a.name, a.port); });
z2.on('error', (e) => { console.warn('Zero2', 'Errored', e); });

z1.scan('http', 'tcp', 'local.');
z2.scan('nvstream_dbd', 'tcp', 'local.');

Resulted in these logs:

2019-07-11 15:52:59.543 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Started'
2019-07-11 15:52:59.543 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Started'
2019-07-11 15:52:59.544 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', 'nas01'
2019-07-11 15:52:59.545 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', 'nas01'
2019-07-11 15:52:59.546 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', 'nas02'
2019-07-11 15:52:59.547 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', 'nas02'
2019-07-11 15:52:59.547 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', 'Brother PT-9800PCN'
2019-07-11 15:52:59.547 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', 'Brother PT-9800PCN'
2019-07-11 15:52:59.548 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', 'Wide Format Inkjet'
2019-07-11 15:52:59.554 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', 'Wide Format Inkjet'
2019-07-11 15:52:59.555 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', 'Warehouse Office Mono Laser'
2019-07-11 15:52:59.556 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', 'Warehouse Office Mono Laser'
2019-07-11 15:52:59.565 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', 'Admin Office MFP'
2019-07-11 15:52:59.565 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', 'Admin Office MFP'
2019-07-11 15:52:59.567 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', 'Print Corridor Mono Laser'
2019-07-11 15:52:59.567 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', 'Print Corridor Mono Laser'
2019-07-11 15:52:59.570 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', 'Brother PT-9800PCN', 80
2019-07-11 15:52:59.571 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', 'Brother PT-9800PCN', 80
2019-07-11 15:52:59.571 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', 'Wide Format Inkjet', 80
2019-07-11 15:52:59.572 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', 'Wide Format Inkjet', 80
2019-07-11 15:52:59.573 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', 'Warehouse Office Mono Laser', 80
2019-07-11 15:52:59.573 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', 'Warehouse Office Mono Laser', 80
2019-07-11 15:52:59.582 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', 'Admin Office MFP', 80
2019-07-11 15:52:59.582 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', 'Admin Office MFP', 80
2019-07-11 15:52:59.583 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', 'Print Corridor Mono Laser', 80
2019-07-11 15:52:59.583 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', 'Print Corridor Mono Laser', 80
2019-07-11 15:52:59.592 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', 'nas01', 5000
2019-07-11 15:52:59.592 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', 'nas01', 5000
2019-07-11 15:52:59.619 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Stoped'
2019-07-11 15:52:59.620 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Stoped'
2019-07-11 15:52:59.621 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Started'
2019-07-11 15:52:59.621 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Started'
2019-07-11 15:52:59.622 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', '3.17.0.126-OLI-XPS-2017.e28f9ad9-17fa-4147-977c-f34f7a1fcdc3'
2019-07-11 15:52:59.622 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', '3.17.0.126-OLI-XPS-2017.e28f9ad9-17fa-4147-977c-f34f7a1fcdc3'
2019-07-11 15:52:59.629 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', '3.17.0.126-JACOB-XPS-2018.05c02740-7670-4c7e-a7e8-3573f491ee46'
2019-07-11 15:52:59.630 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', '3.17.0.126-JACOB-XPS-2018.05c02740-7670-4c7e-a7e8-3573f491ee46'
2019-07-11 15:52:59.631 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', '3.18.0.102-LIAMS-XPS-2017.d33836e8-ffcb-4be8-bece-ec4c881229b7'
2019-07-11 15:52:59.632 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', '3.18.0.102-LIAMS-XPS-2017.d33836e8-ffcb-4be8-bece-ec4c881229b7'
2019-07-11 15:52:59.632 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', '3.19.0.94-ROSS-XPS-2017.46b86b9a-df01-4758-a265-eb5b5e482f73'
2019-07-11 15:52:59.633 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', '3.19.0.94-ROSS-XPS-2017.46b86b9a-df01-4758-a265-eb5b5e482f73'
2019-07-11 15:52:59.634 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', '3.15.0.164-PHIL-XPS-2017.6e590149-a6ae-420f-b8cf-fdea6b573099'
2019-07-11 15:52:59.635 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', '3.15.0.164-PHIL-XPS-2017.6e590149-a6ae-420f-b8cf-fdea6b573099'
2019-07-11 15:52:59.635 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', '3.18.0.94-ALASTAIR-XPS-20.e5fdbf51-5323-4238-993c-8c993a992773'
2019-07-11 15:52:59.635 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', '3.18.0.94-ALASTAIR-XPS-20.e5fdbf51-5323-4238-993c-8c993a992773'
2019-07-11 15:52:59.640 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'FOUND!', '3.17.0.126-ANDY-XPS-2016.4a07b9cc-a785-4c09-b24b-a4f4eeb0627a'
2019-07-11 15:52:59.640 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'FOUND!', '3.17.0.126-ANDY-XPS-2016.4a07b9cc-a785-4c09-b24b-a4f4eeb0627a'
2019-07-11 15:52:59.641 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', '3.17.0.126-OLI-XPS-2017.e28f9ad9-17fa-4147-977c-f34f7a1fcdc3', 47989
2019-07-11 15:52:59.642 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', '3.17.0.126-OLI-XPS-2017.e28f9ad9-17fa-4147-977c-f34f7a1fcdc3', 47989
2019-07-11 15:52:59.644 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', '3.17.0.126-JACOB-XPS-2018.05c02740-7670-4c7e-a7e8-3573f491ee46', 47989
2019-07-11 15:52:59.644 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', '3.17.0.126-JACOB-XPS-2018.05c02740-7670-4c7e-a7e8-3573f491ee46', 47989
2019-07-11 15:52:59.647 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', '3.18.0.102-LIAMS-XPS-2017.d33836e8-ffcb-4be8-bece-ec4c881229b7', 47989
2019-07-11 15:52:59.648 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', '3.18.0.102-LIAMS-XPS-2017.d33836e8-ffcb-4be8-bece-ec4c881229b7', 47989
2019-07-11 15:52:59.649 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', '3.19.0.94-ROSS-XPS-2017.46b86b9a-df01-4758-a265-eb5b5e482f73', 47989
2019-07-11 15:52:59.650 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', '3.19.0.94-ROSS-XPS-2017.46b86b9a-df01-4758-a265-eb5b5e482f73', 47989
2019-07-11 15:52:59.652 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', '3.15.0.164-PHIL-XPS-2017.6e590149-a6ae-420f-b8cf-fdea6b573099', 47989
2019-07-11 15:52:59.652 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', '3.15.0.164-PHIL-XPS-2017.6e590149-a6ae-420f-b8cf-fdea6b573099', 47989
2019-07-11 15:52:59.653 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', '3.18.0.94-ALASTAIR-XPS-20.e5fdbf51-5323-4238-993c-8c993a992773', 47989
2019-07-11 15:52:59.654 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', '3.18.0.94-ALASTAIR-XPS-20.e5fdbf51-5323-4238-993c-8c993a992773', 47989
2019-07-11 15:52:59.655 [info][tid:com.facebook.react.JavaScript] 'Zero1', 'Resolved', '3.17.0.126-ANDY-XPS-2016.4a07b9cc-a785-4c09-b24b-a4f4eeb0627a',47989
2019-07-11 15:52:59.655 [info][tid:com.facebook.react.JavaScript] 'Zero2', 'Resolved', '3.17.0.126-ANDY-XPS-2016.4a07b9cc-a785-4c09-b24b-a4f4eeb0627a',47989

The order of the scan calls seems important: swapping them over changed which scan was performed in which order and as such, which scan was left running.

I expected z1 to only get the Bonjour updates for events relating to the http search ran on it, and z2 the to only nvstream_dbd search.

Finally, the first search isn't always executed - presumably if the second is initialised before the first has properly started, it's switched and doesn't ever actually run the first search.

The issue is most likely a bridging issue, and identifiers for each instance should be used for the bridge messages.

I got same error.