Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Telnet library for JavaScript?

Tags:

We have a network camera. It has an HTTP server to provides the current image. There is also a Telnet interface for controlling the camera (i.e. trigger, focus, etc.). I would like to add an HTML page to the camera that would provide a simple interface (we already have client software we write). I can "GET" the image and display that, but I would also like to have controls that use the Telnet interface to control the camera. So a button might have JavaScript code behind it that connects to the camera via Telnet (logs in) and issues the command to trigger the camera.

I know that JavaScript/browsers support connecting to the same host via XMLHttpRequest. In this case I would be looking to open a socket on port 23 and send text. I also know that I can do this through Flash, Java, or some other technology, but I would prefer to use JavaScript only. If that is possible.

like image 215
Pat O Avatar asked Jan 18 '11 15:01

Pat O


People also ask

Can you telnet from browser?

It allows you to execute shell commands on a server directly from a browser. Just enter the host name and port to connect and click the connect button. It is easy to use and very intuitive. Connect to telnet Telnet, SSH server, BBS service in your browser.

What is the difference between Telnet and SSH?

Telnet transfers the data in simple plain text. On other hand SSH uses Encrypted format to send data and also uses a secure channel. No authentication or privileges are provided for user's authentication. As SSH is more secure so it uses public key encryption for authentication.

Is Telnet obsolete?

On recent versions of Windows, neither the telnet client nor the telnet service is installed by default, but they are still available as features. Years ago, they were used as a terminal service system to manage remote hosts.


2 Answers

Thomaschaaf is correct, while HTML5 introduces websockets you'll find they still require special server support as they post HTTP style information upon opening the socket:

JS/HTML5 WebSocket: Connect without HTTP call

The best way, currently, to have true sockets is to either

  • use a flash or Java component on the webpage that does the actual socket work.
  • use a proxy server with websockets that can handle the additional protocol overhead of websockets and connect to the real tcp/ip port with plain sockets.

The jsterm example Matt linked does the latter, and if your webcans are behind a firewall it will not work in your situation without also implementing another server.

There are libraries that implement the first method, two are linked here for convenience, many others can be found using a search engine:

http://stephengware.com/proj/javasocketbridge/ (Java)

http://matthaynes.net/blog/2008/07/17/socketbridge-flash-javascript-socket-bridge/ (Flash)

like image 157
Adam Davis Avatar answered Sep 19 '22 16:09

Adam Davis


jsTerm is an HTML5 implementation of a Telnet client.

You'll need a browser that supports HTML5 WebSockets. WebSockets is the only method of doing non-HTTP requests with pure JavaScript.

like image 41
Matthew Cook Avatar answered Sep 17 '22 16:09

Matthew Cook