I'm currently looking for a library to allow me to use a RFC2217 serial over IP server through only a webpage.

Currently I can only find clients written in languages such as python and Java, but I really need something that can run in the browser.

Anyone able to help?


for anyone who stumbles upon this question i can confirm that as of april 2017 there is currently no way to implement this in javascript. RFC2217 is essentially another layer on to of telnet, in order to establish a telnet connection a raw socket is needed, in a modern browser a raw socket cannot be obtained, only a websocket. As a websocket is initiated as a http request and requires a suitable answer from the server to keep the connection alive, when the server does not give a suitable reply (because it's not programmed to) the browser will terminate the connection.

both chrome and firefox do offer a socket API, but this is not available in javascript, only to apps or extensions running in the browser, hence not available to a normal webpage.

  • I've seen a Chrome app called "Cleanflight configurator" making a connection to a serial device. Maybe JS for web is that much restricted, but JS for Apps is not? Is it ok for you to use a Chrome App instead? – ogurets May 17 '17 at 19:00
  • as noted above, a socket api (what would be required) is available only to apps in chrome and firefox, and not possible in normal javascript. for my porposes this is not suitable, but i noted in the answer for other people. – James Kent May 18 '17 at 12:19

NO - you cannot access the COM port of the client from the web

Browsers should not expose the hardware to the web. You really do not want to be able to access a web page and have it be able to query your ports and use them to send or receive signals.

While some hardware options has been abstracted and made available to the web (such as microphones and cameras), this is not the case of COM ports.

This is the way it should be. Therefore, if you need a solution to work only with web technologies you are out of luck.

You could access the COM port of the server from the web

If you need to expose the COM port of a computer to the web such that you can use it remotely, what you could do is set up a server on the computer and use server side code to access the COM port.

Doing this is not advice. If you want to do this, you will have to not only worry of having a authentication to prevent sure random people access your hardware, but also to prevent multiple clients using the same port at the same time.

There is code available in the common server side languages (such as Java, Python, even PHP) that you could be adapted for this purpose.

You could hack your way to the client COM port

If you are willing to use a crappy web browser that lets you run ActiveX, you could develop or try to find an ActiveX that allows such connection.

ActiveX can do virtually whatever it wants on the client computer. There are some hoops to jump. Once you understand that this opens a vector of attack to the client, you will also understand why we have moved away from this technology.

Let me paraphrase that: DANGER! DANGER! DANGER!

Now, why do you need to do this from the web?

If you need to access the client COM ports, the only kind of legitimate reason I can think of is that you trying to avoid installing software. If that is the case - in my opinion - you are doing things wrong.

  • If not altering the software on the machine is a workplace policy and you need this for your work. I would have to advice to follow the bureaucracy of your company.

  • If for whatever technical reason you cannot alter the software on the machine, try booting with live CD or USB that allows you to load the tools you need.

  • Are you sure you cannot use a different machine to access the device you need to communicate to? Perhaps one without the software restriction. I know we could be talking about buying another machine, perhaps you could do with something small, like an Arduino or a Raspberry Pi.

  • Ok, stop trying to hack people already.

  • i'm not trying to expose a com port of the machine running the browser, i have a hardware device running an RFC2217 serial over IP server, so i can connect over IP to send data out of the hardware COM port. but i need a javascript library in order to connect to the port to send it the right signals to do so. – James Kent Apr 26 '17 at 17:43
  • i know it does, i need to send commands to port 10001 running on the client device, i do not need to run javascript on the device, its a lantronix UDS2100. it has a poor imitation of a webserver onboard because that is not its primary purpose, it is a serial over IP bridge. – James Kent Apr 26 '17 at 17:47
  • @JamesKent What I understand is the following: you have multiple Lantronix UDS2100 on a network, and you have web application that you want to allow to tell the local UDS2100 to connect to a remote one. Now, Javascript on the client can't talk to the serial port. Perhaps it is possible to use javascript to talk to the web server on the UDS2100, but it would custom for this product, not a generic solution. Edit: I haven't found how the connection is stablished on the manuals. – Theraot Apr 26 '17 at 18:09
  • @JamesKent Here is an idea: setup a custom url handler, that will call a desktop application that performs the connection to the serial port. This way Javascript can initiate the action from the browser. – Theraot Apr 26 '17 at 18:16
  • i cannot set up a custom handler, the device does not support it. it can only serve static files or handle commands to the RFC2217 server on port 10001. this is why i want a javascript lib to run in the browser (served from the device) that can then connect back to the device on port 10001 and issue the RFC2217 commands. – James Kent Apr 26 '17 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.