My web application needs to connect to a local device on the network to get data.
The device has a static IP address and communicates via the P03 protocol. When I connect with Telnet, the device returns a plain text in my console.
I need to do the same thing with JavaScript in-browser. When a user clicks a button, it should connect to 192.168.0.1:8000
via TCP and display the received text data on the page.
The problem is that is a web application. Is it possible to do client-side?
(I'm also willing to accept other suggestions besides JavaScript.)
Unfortunately, you cannot connect to just any TCP socket. The browser can make connections, but it has to be one of these protocols:
One way to do this is to run a proxy of sorts. You need to make a proxy that accepts Web Socket connections from browsers, and then relays the sent/received data to this TCP server. The downside is that this requires a server.
Another way is to make a browser extension. See also: https://stackoverflow.com/a/17567373/362536
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With