Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to open a WebSocket to client localhost?

I've to design a solution that permits to read real-time data generated by local sensors through a remotely-hosted web application.

The design is still work in progress: the sensors' data could be handled by a windows application/service installed on the client machine, or by some external hardware (like a raspberry) located on the same network of the client machine.

Now, I'm very new to WebSockets, but they seems exactly what I need for providing real-time data via browser.

My question is: can a remote web application open a WebSocket to a server that is located on the same local network which the client belongs to? Is solution B possible? How can I achieve that? design For example, I'd like the server to be located on the client localhost. Sensors would send data to the local windows service, and the web application would show them by opening a WebSocket to localhost (client localhost, not server localhost!).

like image 780
blian Avatar asked Nov 15 '25 22:11

blian


1 Answers

Well, I did some testing and the answer is yes, it is possible. Test setup:

  • A web page hosted on a remote server, with a WebSocket client which connects to 'localhost'.
  • WebSocket server running on my pc.

It worked.

like image 163
blian Avatar answered Nov 18 '25 10:11

blian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!