Local Network Service Discovery Using WebSockets

I have a web application running in an external web connection that connects via the tcp WebSocket protocol to an Android device on the same local network via WiFi.

Currently, the Android device installs the WebSocket server (since most web browsers do not support the WebSocket server, creating it that acts as the server), and I manually insert the IP address of the device into the web application and click "connect" to start communication.

I would like to make this connection automatically by creating a web application to search websocket servers on my local network. How can this be done? Will brute force be used when trying to connect to all possible IP addresses? Is there any other effective approach?

Thanks.

+5
source share
1 answer

A proactive approach will work if the subnet is small, most home routers have small subnets ... However, in a more complex network, an iterative approach would not be feasible, you would need to use a service discovery protocol such as mdns or ssdp. However, they are probably inaccessible to a web browser, the best option as an alternative would be a server sitting on the Internet, where devices can meet and exchange local IP address information ... However, if the network is quite complex, even devices with the same external The IP address may not be able to communicate between their respective subnets.

+1
source

All Articles