alexzaizar09
alexzaizar09

Reputation: 514

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?

Upvotes: 0

Views: 2013

Answers (2)

Nathan Bland
Nathan Bland

Reputation: 245

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.

Upvotes: 1

Luis Maldonado
Luis Maldonado

Reputation: 378

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.

Upvotes: 0

Related Questions