Concurrent Android - bonjour discovery possible?

174 views Asked by At

I am trying to use the Bonjour feature to detect other instances of my application and use WiFi p2p communication. My app includes a server and a client part. The (headless) server continously announces its services and the client seeks for servers. When a client sees the server's bonjour announcement, it announced its local service and the connection is initiated by the server - all this to make the PBC dialog occur on the client device.

All this seems to work fine except that the service discovery is terminated when the client sees the server. Since the advertisement of the client's local service is to be triggered by the server's presence (plus user interaction), the server needs to pickup the clients service announcement.

It does not work. Is there a limitation in the bonjour protocol? Can there only be one part that is advertising a local service? Or is this a limitation in the android implementation?

1

There are 1 answers

3
Dr.Jukka On

in Theory it should work just fine. So I'm assuming that your Server is doing the advertisement of the service all times, and same time its doing Service discovery.

if So, then you might want to check my Blog article. Basically in my tests I have seen the Discovery to not find anything on repeated time periods, thus when you do testing, do remember to switch WiFi off/on manually time-to-time, or reboot the device to get fresh start.

Second issue might be that, in my observations I have seen that the device advertisement of a service is only visible when the API is active, i.e., Do try continuing the Peer discovery process, and see whether it would make your client discoverable.

one other nice issue could be that you simply have too long instance name with service, or it could be yet another feature which I haven't discovered with the API yet.

BTW, in case your security model allows you to make automated WiFi Access point Connections, and the Clients could live with cutting off their 'normal' WiFi while talking to the server. Then you could consider using the API's CreateGroup method for creating a Access point which your clients could connect automatically without any UI's needed to be accepted.