How to make a Command Line application with WebRTC in Linux? - javascript

I have an idea for a side project where i will connect two terminals(clients) using WebRTC and they will share some data with each other(assume a CLI chat app) using Node.js. But wherever i read about WebRTC it always says that it works only in browsers. Like the fact that if a machine does not have a browser that supports WebRTC then it would not work in the machine. Do statements like these mean that WebRTC can only work in the browser. If not then how should i approach making something like this?
The functions i want the application to have :-
1.) It should connect with the peer when i write "node client.js" in the terminal (client.js will be the client script).
2.) The terminals should be able to send each other messages.
3.) No need of the browser.
I've made such applications using WebSockets and i dont intend to use them in this project.

Yea this is possible, and people are doing it today!
Check out ascii it is a command line WebRTC client that does camera capture and encoding. It uses the Golang library pion/webrtc
I am sure it is possible with nodejs as well, but don't know how much work it would be.
Also if you are doing chat only it is even easier! See pion-to-pion really easy example to have two processes communicate via WebRTC.

Related

VNC server and vnc browser client

I am looking to add vnc connectivity into a web application to view VM thats are on a server. I have investigated a few projects such as no-vnc and angular-noVNC for the front end frameworks. These look quite simple and easy to implement but i am concerned around the backends and how to implement. Now from what i can see people tend to be using websockify to convert the traffic over to websockets for the browser to handle.
My current arch is windows servers with Vmware hosting the Virtual machines. VNC is out of the box with VMware and i would like to make use of it to view the virtual machines
Can anyone point in the right direction to achieve a suitable backend system to allow my angular front end to connect into. I would prefer it to be open source but would consider a commercial bit of software.
I don't mind what the backend technology is used but would prefer Node or Asp.net.
many thanks
I have found a solution and opted for guacamole server, running on ubuntu server.
The also have client which is built in Js and hence should be fairly straight forward to implement in angular.
All information can be found : - https://guacamole.incubator.apache.org/
Also found that this script was helpful to get install - Tested and confirmed working on Ubunutu 16.04
https://www.chasewright.com/guacamole-with-mysql-on-ubuntu/
Now just need to figure out how to connect different clients with different settings, but i expect it will be fairly straight forward.
Thanks

How to detect a server in the network using JS?

Basically, I want to make a peer to peer architecture, using JavaScript (Ionic).
Since, JS cannot create sockets/etc; a NodeJS server has to be introduced between the clients; acting as the Socket.IO server between the clients.
The problem with this, is that the Socket.IO (NodeJS) server would need to be automatically found within the local network -- by the clients (instead of hardcoded/configured).
Are there any ways to implement such a thing; or alternatives to this architecture?
Thanks for the help!
Are there any ways to implement such a thing; or alternatives to this architecture?
Currently your architecture is using a browser app plus a Node app that users need to have on their network just to create TCP connections.
What you can do instead is create an Electron app that combines a Node app, a browser app, and a browser itself. See:
https://electron.atom.io/
With Electron you can write your frontend code almost the same way as for the regular browser, but you can use the entire Node API including the TCP sockets so there will be no need to create a separate Node app and to search for that app in the network. This can greatly simplify your architecture.
Note: this is not an answer to the first part of the question: "How to detect a server in the network using JS?" but to the second part of the question: "Are there any ways to implement such a thing; or alternatives to this architecture?" Detecting the servers on the local network with client-side JavaScript will not be easy - and in fact it shouldn't be even possible because websites being able to scan your LAN for active services would be a serious problem for privacy and security.

Modbus TCP communication from HTML/Javascript Webpage

I have a device that uses Modbus TCP. I want to read data from it and display it on a webpage (Without an in between server).
I have found a project that does almost this exact same thing as a Chrome extension:
https://github.com/Cloud-Automation/chrome-modbus
It uses this in the javascript code: chrome.sockets.tcp
I was hoping that I could do the same thing on my webpage using WebSockets.
It seems that websockets would work on my webpage (acting as the client), sending and receiving information from the device (acting as the server). It doesn't seem that websockets is affected by cors.
Does anybody have pointers on where I could start on this? (Or a javascript library would be great)
Is this possible?
Without an in between server will not be possible, unless your plc supports other protocol different than modbus (e.g. post/get).
If your plc is "completely closed" and you only have this port/protocol open, then you need an in between server that makes the conversion of modbus tcp to html. Using node-red as well as the dashboard and modbus flows, you can achieve it.
If you solved it other way, I would like to know how you did it.
I did get this solved without a server in between. I did it using Chrome Sockets link I also made it work using a cordova app for smart phones. Firefox has a sockets api as well, but did not attempt to figure it out for that browser.
I solve this using the PLC Connect in vb, i used vb to pass data in database and get the data through javascript.

peer to peer communication between mobile app and pc browser

I am working on a project where i need my mobile application to talk to my web browser on a pc, where both devices are connected over wifi. The app would send data which would be received by the computer browser followed by some client side code execution. The browser then may send some feedback.
My initial approach is to make the app talk to an endpoint which in turn talks to client side of the browser (javascript).
What could be the best approach to do this ?
Update
I am not sure if Socket.io is a possible solution since it requires a server to be hosted. Is it possible to solve this using sockets ?
You've now edited your question to mention P2P. That's quite hard to achieve PHONE TO BROWSER (i.e., by hard I mean 6 to 12 man-months of work - and/or plain not possible). However in MOST situations you can instantly (ie "one line of code on each platform") resolve the problem by using a service like pubnub. Much as nobody has back-ends anymore and everything is just done with parse.com or game center, networking like you mention is now just done with pubunb (or any competitor).
This is an extremely common use case problem - and everyone just uses PubNub as mentioned below or one of its competitors.
These days it couldn't be easier, just use pubnub.com
It's the world's biggest data-messaging service for a reason!
There's essentially no other realistic approach, it's so simple - a few lines of code.
So short answer would be: A real peer-to-peer (P2P) communication is currently not possible with all browsers. So instead you have the following options:
App + Server with a WebUI (maybe)
App + Chrome App (Chrome Apps can start an web server, see http://www.devworx.in/news/misc/chrome-apps-can-now-run-a-web-server-135711.html)
App + WebApp with Plugin (Flash, Silverlight or Java)
I personally would prefer solution 1.
You need a server. If you consider this problem strictly from the typical firewall point of view, a PC or a mobile device are going to ignore connections unless they initiate the connection themselves. So neither the PC nor the mobile device can start a connection with the other.
My understanding is that web browsers do not support standard sockets within javascript. You can use the analagous websocket, but sockets and websockets are not directly compatible.
You can setup a simple server on the PC, and have this server relay messages between the mobile device and the PC browser. Both the mobile device and the PC browser connect to the server. This is basically what an external service will do for you.
PeerJS is what you're looking for:
http://peerjs.com

send command via tcp ip through javascript

I want to achieve following functionality and need the help for the same:
I have one server on which there is device connected that prints some bar codes based on pre-formatted command given to it.
Currently there is one desktop application which generates the command and does the job.
Now I want to do this via web, meaning there will be one webpage (say .aspx) and I want to achieve this by javascript.
I am able to generate the pre-formatted command required for printing but I don't know how to send the command to server, whether socket tcp ip or something else.
I have tried using node.js, socket.io, json-socket etc. but nothing is working,
If javascript is a fixed requirement, then no I don't think you'll find a direct solution. You will need to create an intermediary service that will translate websocket protocol to the tcp/ip protocol your software communicates on. I found a package called Websockify that has implementations of this kind of bridge in a few different languages.
Although if you are open to using Flash on the front end, and can meet the security requirements on your backend connection, then Flash socket API could work. I believe Java applets can also manage this.
I don't believe this is possible to do from inside a web browser. If it were it would be a huge security vulnerability (think about it, you visit an attackers page and all of a sudden your printer starts printing and every shared directory on your network fills to the brim with junk data).
You could run the command on the server (node/.net/anything else...) and have the web platform talk to the server to kick the process off. But that sounds kind of like what you already have set up...
Alternately, if you can change the software on the connected device you could try to give it an HTTP endpoint which responds to POSTs.

Categories

Resources