asp.netwebsocketblazorblazor-webassembly

Can two Blazor WASM clients communicate with each other in local network?


Is it possible in a blazor wasm webapp, that two clients communicate with each-other (e.g. via sockets)?

With desktop apps this obviously was possible. Now with WebAssembly, web-apps can run offline. And I wonder, would it be possible to "install" the WASM app as an app offline, then disconnect from the internet, connect to a local network, and share updates with another wasm client? (e.g. by using a broadcast for discovery etc.? Perhaps by using Http and exposing a webapi within the webassembly app?).


Solution

  • Browser cannot become server for any external application or clients on other network, that is because there is no port listening API setup in web browser and I don't think there ever will be.

    You will need some web server to communicate with, as browsers are designed to contact a webserver or use local apis (manifest with service). Multiple instances of same browser can communicate with each other on the same machine.

    As others have mentioned, you have to install web server in your local intranet to communicate between other people on the same network. And you will need SSL setup as many APIs are now only available under secure context.