3

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!).

blian
  • 103
  • 1
  • 6
  • is it possible to send any data from sensor to websocket server? – raj peer Jul 26 '17 at 09:31
  • Yes, i'm going to implement a Windows application that reads data from sensors and sends them when there is at least a client connected (producer-consumer pattern) – blian Jul 26 '17 at 14:51
  • I found your question after observing this behavior from the TD online banking website. – Altimus Prime Jul 14 '20 at 15:58

1 Answers1

2

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.

blian
  • 103
  • 1
  • 6
  • Hello, I'm trying to do the same thing, open a webscoket on localhost from a n html page on a webserver. Is your solution still running ? I don't have success to make it runs. – herve Feb 22 '18 at 15:12
  • 1
    Yes, it is working. Machine A hosts the web socket server, machine B hosts the web application. The interested web page connects to a localhost web socket. When the web page is open from machine A, web socket trasnmission just works. – blian Feb 26 '18 at 14:00
  • @blian did this solution require any hacks, or was it just as simple and straight forward as you present it here. I'm trying to do same for similar solution – Charles Okwuagwu Jan 04 '22 at 01:11
  • 1
    @CharlesOkwuagwu no hacks, the solution is very simple as it seems – blian Jan 10 '22 at 20:05
  • @blian confirmed got it working too – Charles Okwuagwu Jan 10 '22 at 20:42