Ammar Tariq
Ammar Tariq

Reputation: 847

Peer to peer connection on LAN using Node js

I'm working on a data sharing app using node js, the idea is to create an application that can connect peers using node-js without using any kind of central dependency i.e a signalling server or something of its kind. After a lot of research I'm always back to this diagram but it only makes sense if there is no signalling server I'm targeting LAN networks so that I don't have to deal with NAT.

To be specific, I would like some to answer these specific question

  1. Is it possible to connect to webrtc on LAN, i.e the webrtc connection will connect using my client's ip
  2. Is it possible to use websockets without a central server, or something like websockets
  3. Is it possible to connect two clients on LAN using node js without using any hardcoded Ips or asking users to enter ip.

Peer to peer architecture

Upvotes: 3

Views: 2125

Answers (2)

Mohi Rostami
Mohi Rostami

Reputation: 1074

The answer to all your questions is Yes!
Also, there is a lof WebRTC server that you can use them on a simple Linux box, like Janus, Kurento, etc. I've tested them and they have worked with some mischief, lol. So, run it and next read their API to exchange anything you want on their medium.

I'm not sure about Janus but the Kurento has a nodeJS client itself. Read the Local Installation and JavaScript Kurento Client.
Additionally, if you want to make a WebSocket connection, it has enabled by default configuration.
To change the port, enter this command at the final step:

npm start -- --ws_uri=ws://https://185.164.72.144/:8888/kurento --as_uri=https://185.164.72.144:6008/

Upvotes: 0

YellowAfterlife
YellowAfterlife

Reputation: 3202

Since you are using node.js, you can very well use raw UDP (dgram) and use UDP broadcasting for device discovery - then you do not need any form of centralization required by websockets/webRTC.

Upvotes: 1

Related Questions