Websockets and telnet connection - javascript

Does anyone know if it is possible to use HTML-WebSockets to listen to a telnet stream?
Description: I have a DSL-Phone-Router (Fritzbox) which has a "Callmonitor"-function. This sends for every incomming/outgoing call a telnet line with specific infos.
I can see this stream, when i run...
telnet fritz.box 1012
on my Windows-CMD or MAC-Terminal.
My Question: Is it possible, that HTML5-Websockets can listen to this stream? Or can HTML5-Websockets only listen to a Websockets-Server like node.js etc...?

The websockify project was created for exactly this sort of thing. It is a python program that bridges between the WebSocket clients and raw TCP servers. You will need somewhere to run websockify, but the websockify requirements are fairly minimal. Also, you will need to implement the client side (HTML/Javascript) to display the stream, but websockify includes a wstelnet.html example that you should be able to modify or use directly for that purpose. Disclaimer: I created websockify.

Related

How can I send notifications from my Java server to my react-native client in realtime?

I would like to send messages from my Java server to my react-native clients.
I don't know exactly how to solve this. Should the server establish a connection to all clients via the IP addresses of the clients and send the message and then close the connection again? (Sounds the most sensible to me.)
I think that would be better than if the clients connected to the server and the connection should always be maintained. After all, it should run with high performance.
Basically, it doesn't make much sense for my system that the clients connect to the server, since only the server knows when and whether it is sending a message.
I've already tried working with websockets. However, it didn't seem to work without requests from clients.
The difficulty is to find a method that works with Java on the server side and JavaScript on the client side and that the connection is made from the server to the clients and not from the clients to the server. In addition, the transmission should work in real time.
Is that feasible? Are there any better ways? How can I do it?
I hope you can help me.
Greetings. Martin
The basic function of the system
There are multiple cloud based messaging platforms. One of them is Firebase from Google which is free (I guess). Check this out here. https://firebase.google.com/docs/cloud-messaging
You will find multiple tutorials to configure and use it in your react-native and Java server.
Architectural overview: https://firebase.google.com/docs/cloud-messaging/fcm-architecture
Another solution is writing your own logic using the WebSockets.
Lifecycle of message: https://firebase.google.com/docs/cloud-messaging/fcm-architecture#lifecycle_flow

how to connect vue with a raw tcp node server?

the client i am working with has a node js tcp server working with gps trackers through raw tcp. This trackers can not be upgraded to use socket.io or any other library. They simply send raw data.
My work is to upgrade the client and admin communication, currently they login by console using netcat ip port and typing the command they want to execute.
My idea is to use vue since they woule like realtime communication and better ui/ux. I have no idea how to make a raw tcp tranport with vue. any help?
The short answer to this question, is that the browser cannot directly use raw TCP connections. If the browser is your only option you are probably out of luck.
However if you still want to use vue you have a couple of options. You could implement a kind of TCP-socket-bridge. Such as ws-tcp-bridge. You could also write your own middleware server to dispatch events in node.js, using something like the example here.
A third option would be to do something like electron-vue and use its node instance to relay the data to vue with a websocket or socket.io. Here is an example of an express server with electron.
Good luck, and sorry it isn't easier.
Im just thinking above my head here. But what about having maybe a bash script that post to a webhook back and forth. You can post to an endpoint and run a bash script behind cameras, and this same script post back to another webhook that you will be listening to. It wont be fast i believe but it will get the job done. You just have to manage the queue and the webhook listening. Also be sure to limit the webhook origin request to your app only.
Bash easily can save the output of a netcat command, and also this way you isolate the raw tcp communication, giving it an extra layer of security.

NodeJS communicating with other NodeJS instances and managing minecraft server

I was wondering how would I communicate with another NodeJS instance? For instance I have one NodeJS instance that is a chat room, how would I get the chat and all people connected to the chat from another NodeJS instance.
Secondly I was also wondering is it possible to manage Minecraft servers using NodeJS so for example create a directory copy all the necessary files then start the server with x amount of ram and be able to receive output of the server and send console commands.
You have many options, Socket.io, Rest, Soap, TCP/IP or even low-level protocols. Really depends on what is supported by Chat node. If you are the owner of both nodes, then I would suggest to use Socket.io, it is more real time and supports push-based communication, otherwise you will have to periodically hit REST or SOAP API of remote node.
As far as NodeJS is concerned it can execute shell commands for example. From there it is upto Minecraft what it offers and adheres to.

Javascript client C++ server game

I have a question which path should I follow.
I want to develop real time online game via webbrowsers.
I would want to write game server using C++ with TCP sockets listening. The client side game will be written in javascript. The only problem I dont know how to communicate javascript with c++ server using TCP sockets. I have considered using Socket.IO but as far as I know this library does not have option to just connect to real TCP server, push bytes through and read incoming ones. Instead I would need to use some wrapper like Node.JS server which I want to avoid.
Anyone could guide me which path I should take?
You could make your game server itself an HTTP server. For the most part it could just serve up your static files, but when it received a WebSocket upgrade request, it could handle that however it desired.
You should take a look to websockify:
websockyfy is a WebSocket to TCP proxy/bridge. This allows a browser
to connect to any application/server/service. Implementations in
Python, C, Node.js and Ruby.

Is there a Telnet library for JavaScript?

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.
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)
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.
Currently there is no way to do socket connections with JavaScript only.
But what you are searching for is a socket connection ;)
https://developer.mozilla.org/en/XML_Extras
If I interpret the question liberally as "is there a remote connectivity library for Javascript", then the answer is yes (quoting from https://xtermjs.org/):
A web based SSH2 client using xterm.js, socket.io, and ssh2: https://github.com/billchurch/WebSSH2
HTML5 Based SSHv2 Web Client with E2E encryption utilising xterm.js, SJCL & websockets: https://github.com/stuicey/SSHy
I've tried WebSSH2 with node.js briefly, it worked for me - I managed to connect to a Linux-based server with it.
(I know this probably doesn't help the OP but this is a 7-year old question anyway. Maybe it helps others who are needing an answer to a similar problem.)

Categories