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.
Related
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
What's the difference between socket.io-client and socket.io ?
I also find a bit confusing that socket.io-client also has a section for "server-side usage"
socket-io.client is the code for the client-side implementation of socket.io. That code may be used either by a browser client or by a server process that is initiating a socket.io connection to some other server (thus playing the client-side role in a socket.io connection).
A server that is not initiating socket.io connections to other servers would not use this code. This has been made a little more confusing that it probably should be because when using socket.io, it appears that both client and server are using the same socket.io.js file (because they both refer to a file with the same name), but is not actually the case. The server is using a different file than the client.
From the Github page for socket-io.client:
A standalone build of socket.io-client is exposed automatically by the
socket.io server as /socket.io/socket.io.js. Alternatively you can
serve the file socket.io.js found at the root of this repository.
Keep in mind that there are unique features that belong to client and server so it should not be a surprise that they use some different code. Though they share code for parsing the protocol and things like that, the server has the ability to run a server or hook into an existing web server and it has methods like .join() and .leave() and data structures that keep track of all the connected sockets and is expected to live in the node.js environment. The client has the ability to initiate a connection (send the right http request), do polling if webSockets are not supported, build on a native webSocket implementation if present, etc....
I'm creating an app where the server and the clients will run on the same local network. Is it possible to use web sockets, or rather more specifically, socket.io to have one central server and many clients that are running native apps
? The way I understand socket.io to work is that the clients read the web-pages that are served from the server but what happens when your clients become tablet devices running native apps instead of web pages in a browser?
The scenario I'm working with at the minute will have one central server containing a MEAN app and the clients (iPads) will make GET requests to the data available on the server. However, I'd also like there to be real-time functionality so if someone triggers a POST request on their iPad, the server acknowledges it and displays it in the server's client-side. The iPad apps will (ideally) be running native phonegap applications rather than accessing 192.168.1.1:9000 from their browser.
Is this technically possible to connect to the socket server from the native apps or would the devices have to send POST requests to a central server that's constantly listening for new 'messages'? I'm totally new to the whole real-time stuff so I'm just trying to wrap my head around it all.
Apologies if this isn't totally clear, it's a bit hard to describe with just text but I think you get the idea?
Correct me if I am wrong.
You have multiple iPads running native app. They send a POST request to your node JS server which is running in a computer in the same local network. Whenever the server receives a request from app, you want to display that a request has been received in your computer screen.
If my assumptions about the scenario is correct, then it is fairly easy to do. Here are the steps to do it.
Create a small webpage (front end). Load socket IO in the front end page like this -
<script type="text/javascript" src="YOUR_SERVER_IP/socket.io/socket.io.js"></script>
Then connect to server using var socket = io(). This should trigger connection event in your backend.
Handle all POST request from apps normally. Nothing special. Just add a small snippet in between. socket.emit('new_request', request_data). This sends new_request event to front end.
Handle the new_request in your front end using socket.on('new_request', function(request_data) { ... });. That's it. No need to add anything to your native app for realtime update.
The second step would be a little complicated as it is necessary to make socket variable available inside all POST requests. Since you chose node.js, I don't think you need any help with that.
Not totally clear on your project, but I'll try to give you some pointers.
An effective way to send data between native apps and a server is using a REST server. REST is based on HTTP requests and allows you to modify data on the server, which can connect to your database. The data returned is typically either JSON or XML formatted. See here for a brief intro: http://www.infoq.com/articles/rest-introduction
Android/iOS/etc have built in APIs for making HTTP requests. Your native app would send a request to the server, parse the response, and update your native UI accordingly. The same server can be used from a website using jQuery ajax HTTP requests.
Express.js is more suited to serving web pages and includes things like templating. Look into "restify" (see here: mcavage.me/node-restify/) if you just want to have a REST server that handles requests. Both run on top of node.js (nodejs.org).
As far as real-time communication, if you're developing for iOS look into APNS (Apple Push Notification Service). Apple maintains a persistent connection, and by going through their servers you can easily send messages to your app. The equivalent of this on Android is GCM (Google Cloud Messaging).
You can also do sockets directly if that's easier for you. Be careful with maintaining an open socket on a mobile device though, it can be a huge battery drain. Here's a library for connecting ObjC to Socket.IO using websockets, it may be useful for you: https://github.com/pkyeck/socket.IO-objc
Hope that helps!
To answer your question, it is definitely possible. Socket.io would serve as the central server that can essentially emit messages to all of the client. You can also make Socket.io listen for the messages from any of the clients and serve the emitted message to the rest of the clients.
Here's an example of how socket.io can be used. Simply clone, npm install, and run using 'node app.js'
All you have to do is to provide a valid server address when you connect your socket from the iPad clients:
var socket = io.connect( 'http://my.external.nodejs.server' );
Let us know if you need help with actual sending/receiving of socket events.
It is possible to connect to Websockets from your apps.
If you are using PhoneGap then you need a pluging that gives support to websockets in your app (the client) and then use websocket like normal way using Javascript see this.
If your app is native iOS look into this it could help you.
The primary use of the Sockets in your case is to be a bidirectional "pipe" between an app and server. There is no need of server sending the whole web-page to the native app. All what you need is to send some data from server to the client(app) in response to POST (or GET) request and then using this data on client side to update client's UI in real-time. If you are going to use moderate amount of devices (say tens of them), you may have connected all of them to the server permanently keeping individual socket connection open for every individual link server-to-app. Thus you may deliver data and update client's state in real time.
In fact web browsers also employ sockets to communicate to web servers. However as in general case there is no control on amount of concurrent clients in Internet, for the sake of limited networking resources conservation, servers do not keep sockets open for a long time, closing it just after the web-page was sent to client (or timeout has expired). That's how HTTP protocol works on the low level. The server waiting for the HTTP clients (browsers) by listening the 80 port, responding them by sending the whole web page content, then closing the connection and keep waiting for another requests on the same port.
In your case it's basically a good idea to use socket.io as it's a uniform implementation of sockets (ok WebSockets) on both client and server side. The good starting point is here
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.
Introduction: I want to develop the chat client that user can chat on the browser and I use the protocol call xmpp. Because of HTML5 web socket not yet available I try flash xmlsocket instead.
Problem: I cannot connect to the server via browser. I'm not sure why, but I think that it is the problem of the server configuration.
Question: Which is the best jabber server suitable for this job?
Most probably this is a permission issue. Either that or you've just configured the wrong host/port to connect to. Flash is not allowed to connect to other hosts than the one it was gotten from itself. You have to explicitely allow flash connections on the receiving side of the request (so on the chat server that you are connecting to). Google for crossdomain.xml to get more info.
ejabberd sounds like a suitable option for you. ejabberd is xmpp server written in erlang and is used quite widely. Many of the well known web based im services like www.meebo.com etc are known to be running on ejabberd. It allows you to install other transports which would let you enable talking to users of other protocol like yahoo, msn, icq etc.
You can also have a look at the xiff action script library by ignite realtime. It is an xmpp client library in action script. If you use this library you would just need to implement the ui components.
Hum... flash is ok, but you'd be better of using something like BOSH, which is basically an HTTP layer over XMPP.
Ejabberd would be a good server, as it supports BOSH, I don't know about OpenFire or Tigase (but I'd say they do). Other servers should be looked at carefully because they don't seem to have a "dynamic" community.
You will need a lot of Javascript, and for that, I can recommend StropheJS, which is probably the very best library out there today.
We have created a MUC (Multi-user chat room) client called Aristochat that works in the browser recently at Superfeedr. You can find the code on Github and an example here.