RTCDataChannel communication between server and client - web

I am going to create real time web application and would like to use WebRTC RTCDataChannel to exchange data between client and server.
WebRTC is created for peer-to-peer communication. However, is it possible to do data exchanging between server and client?

Yes! You could use a WebRTC implementation and build your server from the ground up. Will feel like using a HTTP library and setting your own endpoints.
https://github.com/aiortc/aiortc (Python)
GStreamer’s webrtcbin (C)
https://github.com/shinyoshiaki/werift-webrtc (Typescript)
https://github.com/pion/webrtc (Golang)
https://github.com/webrtc-rs/webrtc (Rust)
https://github.com/awslabs/amazon-kinesis-video-streams-webrtc-sdk-c (C/Embedded)
https://webrtc.googlesource.com/src/ (C++)
https://github.com/rawrtc/rawrtc (C++)
https://github.com/sipsorcery-org/sipsorcery (C#)
https://github.com/paullouisageneau/libdatachannel (C++)
Or you could run a WebRTC server and write an extension/modify it. This will get you something working quicker.
https://github.com/meetecho/janus-gateway
https://github.com/jitsi/jitsi-meet
https://github.com/versatica/mediasoup
https://github.com/pion/ion-sfu
https://galene.org
https://github.com/peer-calls/peer-calls
Happy to answer more directed questions. I think it depends on what languages/tools you feel comfortable with.

Related

WebRTC through host with nodeJS express and socketio

I created a web app to let people communicate. I want to implement screen sharing and audio calls.
My current app is programmed in NodeJs and uses express and socket.io to serve the client connection and open a socket connection. I want to stream video and audio. My problem with WebRTC is that all those who connect to a call are vulnerable to a DDoS attack since it is p2p. I found an article from Discord explaining how they managed to let the entire traffic go through their servers: https://blog.discord.com/how-discord-handles-two-and-half-million-concurrent-voice-users-using-webrtc-ce01c3187429, that's exactly what I want to achieve.
Could I possibly use socket.io-stream https://www.npmjs.com/package/socket.io-stream ? I didn't yet figure out how, and it seems like all socket.io streaming libraries are made for file upload/download, not for actual video/audio streaming.
If that doesn't work, a library such as what Discord managed to make would be the perfect solution, since all traffic is proxied, and not p2p. Though I couldn't find any of those libraries, maybe I'm just looking for the wrong thing?
Best regards
You will want to use a SFU.
Each peer negotiates a session with the SFU. They then exchange media through it. Each Peer will just communicate with the server. It has lots of other benefits and is what most WebRTC deploys today use.
There are lots of Open Source SFUs out there. You can even build your own with Open Source libraries.

Does zeromq provide TCP security while communicating to nodejs apps?

I have integrated zeromq in 5 applications those are running on nodejs and nginx proxy. I want to know the best way to secure the tcp communication between 0mq and nodejs app - I am mostly using PUB SUB method.
Currently for security I am using req rep method to share a key with queue id before any connection. this key I am using into SUB.
What are the best standard for zeromq tcp security?
ZAP CURVE for nodejs zmq lib.
There are few libraries those are in beta but I have implemented Curve Machenism it is working fine no breaking issues
you can use REQ REP also with ZAP module. But best I felt CURVE machenisim.
https://github.com/msealand/zmq-zap.node/tree/master/examples
http://rfc.zeromq.org/spec:26/CURVEZMQ
https://en.wikipedia.org/wiki/Elliptic_curve_cryptography
Just go through documentation and if you face any problem while implementing it please post separate question.

Meteor.js: is the DDP implemenation suitable for an inbox-messaging apps?

I'm looking at Meteor to build a site that is comparable to a stripped-down Facebook. i.e.
It will have users that can connect to other users (either by 'friending' and / or 'following')
users can interact with content that either they or other users create/share
I would like to implement a 'wall' and 'news feed' like concept
The first thing you notice on the framework is how data syncs instantaneously across all clients. I'm assuming this is what the framework refers to as 'DDP'? (Please let me know if that is not correct).
Question:
Is this 'DDP'-like thing reliable enough to build an 'inbox' messaging functionality (i.e. Facebook messenger)?
DDP(roughly) is an efficient combination of some XHR techniques and web socket. And Meteor is a framework to build programs using DDP. You can check the specification.
DDP is a protocol between a client and a server that supports two operations:
Remote procedure calls by the client to the server.
The client subscribing to a set of documents, and the server keeping the client informed about the contents of those documents as they change over time.
If your application needs reactivity and you decides not to use Meteor, you are likely to invent a layer between client and server, which is very similar to DDP.

Node.js with socket.io

I am looking to build an web application using node.js and possibly socket.io but I am having a lots of confusion regarding whether to use socket.io or go with plain http. In the app the node.js server will be basically an api server which serves json to the javascript client or may be mobile clients too. The web app will also has chat messeneger for its users, this is where socket.io comes in.
I am not sure whether to use socket.io for the whole app or only for the chat part. Although my app itself could benefit from socket.io but its nothing that I think can't be done using plain http and client making more requests to the server.
I have read at several places that sometimes socket.io can be difficult to scale for more users.
Socket.io often crashes and specially creates probs when there are firewall in clients system.
More importantly.....I checked out socket.io user list and did not find many users, so was curious to know what kind of platform is more know chat network like facebook messenger, google talk etc are built upon, Are any built using http-ajax and continues querying to the server.
Please help me out in solving this question. Some might argue that this is a opinion based question. But what actually I am trying to figure out the implementation of socket.io and its limitation.
I would suggest serving your API over HTTP and leave the real-time business to Socket.io. If you are adverse to using Websockets, like #GeoPheonix stated, you can choose from a variety of transport methods using both socket.io and sockjs (https://github.com/sockjs/sockjs-node).
As far as scaling is concerned, I deployed a socket.io based real-time analytics/tracking service for a very large application with ana average of 400+ concurrent connections with no visible performance impact, but this may depend on the implementation and hardware.
Socket.io is faster than plain http. I recommend you to use it for all since you have to have a chat in first place.
In my case, real-time Texas Hold'em-like game can receive up to 2500 concurrent with one node process. However, if you change transport from websocket to xhr-polling, It can receive like more 10x than pure websocket. Your application is just chat so, I guess a little slow down wouldn't be a problem. If you sure you will exceed this number, yes, scale socket.io is a pain.
This problem will happen only if you open socket.io for port other than 80 and 443. If you have frontend web server with other language already, you can still use socket.io on another subdomain to be able to run on port 80 without conflict with your main frontend web server. Socket.io support cross-domain without a problem.
Have you used trello.com? If not, try it :). It's best for task management or even some Agile thing. They used socket.io. https://c9.io/ is another one. It's online IDE with google doc-like collaborative. One thing to note is xhr-polling trasport in socket.io is the same with http-ajax with long-polling (Better than general ajax). You can read more info at:
http://book.mixu.net/node/ch13.html

Connect node.js and signalr via sockets

Is there anyway to send data though sockets from Node.JS to SignalR? I have a Node.JS app that sends realtime information as JSON format. The other app it's an MVC C# app that uses SignalR to send the data to the client via socket. I want tosen data from de nodejs to signalr and signal send that info to the client.
You might consider better solution for internal communication between processes. SignalR is meant to be used between .Net server and client using different authentication, handshake, protocol and network layer methods, which is inefficient for internal server communication.
Take a look on ZeroMQ, is well simple and very easy to use tool, meant especially for such cases. It has bindings for most languages including .Net and node.js.
There is js client for browser to communicate with Signal R server.
http://www.nuget.org/packages/SignalR.Js
You probably can extract js file from it and run from Node.js.
And probably standard Socket.IO will just work, you need to subscribe to proper events and go.
If you want a node.js client for signalR that doesn't require jQuery I started this one. It intentionally only supports websockets.
https://npmjs.org/package/signalr-client

Resources