Webtrc broadcast have multiple bandwidth usage - socket.io

I want to create a webrtc broadcasting demo
https://webrtc-experiment.appspot.com/socket.io/
here i have a one problem broadcaster have huge bandwidth when connect 10+ user because it use peer to peer connection so it use upload bandwidth like this
Total upload bandwith = number of user * ( 30 kb approximate to upload 1 video)
so i want to develop like this
http://bloggeek.me/webrtc-multipoint-small-groups
how to i develop multipoint webrtc using minimum bandwidth ?

While your thought of using WebRTC in a small group multipoint manner, this comes with a lot of complexity and reliability issues. Most WebRTC apps that relay through peers tend to be not so reliable in my experience. In concept it's a great idea, but I haven't seen any solid practical applications. The most reliable implementations of scalable WebRTC broadcasts tends to use a server in the middle. You can use something like Janus, but I prefer Kurento which is open source. There is also a platform called OpenVidu that sits on top of Kurento if you don't want to have to get into the nuts and bolts of how things works, but is less customize-able. You can even record, transcode and process the video in real time.

Related

Websocket vs WebRTC for multiple users in same channel?

I want to develop a little rpg game on a web application. To explain quickly, each players have a character sheet and can use skills and attacks that will deal damage to other players.
There is generally 5 players at the same time, and there is a chat functionnality in addition.
I would originally use web socket to make communication between players and server for exchange: messages, damages, or other data that need to be share in other players.
But i see there is the WebRTC too who create a peer to peer communication and exclude the passage by the server. But if I have understand, peer-to-peer is better for only two user ?
I don't understand really what is the best solution in this case and why ?
Best regards.
WebSockets are strictly client-server, just like plain HTTP: every client communicates with the server, and all client-client communication must be mediated by the server. WebRTC, on the other hand, allows clients to communicate directly among themselves, without going through the server. This gives lower latency, and better privacy, since the data does not need to go through the server.
In a large group, however, every WebRTC peer will need to connect to all other peers: with n peers, the total number of connections n(n-1)/2. For example, in a group with just 10 participants, you will need to establish 45 connections. Given the vagaries of the Internet, the probability that none of these will fail is essentially zero, so your application will need to be able to deal with partial connectivity, which is difficult to implement and almost impossible to debug.
In practice, peer-to-peer WebRTC is a good solution for groups with three or four participants, but unworkable beyond that.
Note that WebRTC can also be used in a client-server topology, which gives lower latency than WebSockets without the complexity of peer-to-peer error handling. Doing that requires a server-side implementation of WebRTC (my favourite is Pion), and is probably more involved than what you are willing to deal with.

Does WebRTC makes sense for a a real time app to support many concurrent users?

I want to build a real time online multiplayer game. After researching WebSockets and WebRTC, I've come to the conclusion that WebRTC is exactly what I need if I was building a p2p game. However, WebRTC seems like its not meant for handling group conferencing. This is because if there are "n" users, there will be "n-1" streams of data. This is obviously not scalable. There are smart ways to circumvent this, like using https://github.com/jitsi/jitsi-videobridge and other solutions. But essentially it seems that WebRTC is meant for one-to-one communication. Most of the tutorials out there serve that purpose, not group conferencing.
Questions -
I've read that Google Hangouts and Facebook Messenger use WebRTC for their group video chats but how exactly have they solved this problem?
Are server based Websocket implementations like uws viable for real time communications? (due to added latency)
Is there any plan to address group conferencing from the WebRTC or is WebRTC just not meant for this use case.
Thanks in advance.

Is Firebase's latency low enough to be used for realtime MMOG instead of socket?

I wonder if Firebase's performance (latency, throughput) is good enough to be used real-time MMO games online.
Could someone with enough knowledge share their opinions on this?
Can Firebase be used instead of socket for real time games?
Short answer is NO: with firebase you'll get client synchronised after a couple of 100 of milliseconds. You may also find consuming to much network traffic with would make firebase prohibitively expensive.

peer 2 peer libraries to broadcast real time video using websocket?

First of all, is it a nice and successfull idea to use peer 2 peer to broadcast realtime video ? I know that it will make the application scallable and will allow more users to get the real time video without affecting the server much, but are there drawbacks performance-wise and video quality-wise ?
Now the specefic question, my intention is to share realtime video, and then use peer2peer in the webclient level using websockets, are there any libraries that are used for this purpose?
I know that streaming should be better using UDP but the follwing post says that even using websockets (TCP) at 30fps is fast ennough (Video streaming over websockets using JavaScript)
XSockets.NET provides a WebRTC API.
This will provide you a JavaScript API for P2P communication. You can actually have a video chat with 2 or more participants really easy.
If you are a .NET dev you can install the sample from nuget. That sample contains a example of a multivideo chat.
The video will be of high quality, but you can set parameters to get lower resolution if you have low bandwith.
WebRTC works in Chrome and Firefox today (as well as chrome 29 on android). You can try this site with Chrome (not updated for Firefox or mobile) http://browsermeeting.com/
Nuget Package
You can check out IceLink (disclaimer: I work # FM), it'll help you do this.
I've actually built something along these lines for a client of ours, where each successive client becomes a potential "distribution" node. So X clients connect to the main server, and from there, other clients can connect to those clients (provided they have appropriate bandwidth/CPU/etc) for a re-broadcast version. It's sort of a supernode/mesh concept, and it works reasonably well.

Based on my scenario should i go WebSockets or XmlHttpRequest or both?

I am about to make a turn-based game in the Monkey language (Cross-platform translator). The game will use the HTML 5 platform. This game will play online where players can match against each others (It can be a 2vs2 match). I recently reviewed a tons of solutions and i stopped on 2 of them. The good old XmlHttpRequest and the new one WebSocket which seem to be in a recommandation state from W3C which is rather good. There also another technology which i was interested which is PubNub, a push service. This service actually push messages to all clients connected and is really fast.. but this come at a cost later and is restricted in the number of messages you sent. By that i mean it cost you 15$ per month for 1000 connections and 1million message then +1$ for another 1 million and go on. There actually 3 actors, the client written in monkey (HTML5) the server written in C# because i know well the language and PubNub for broadcasting messages. The client will only send requests to the server and the server is relaying the messages to PubNub which in return send back to clients. I had two plan in head considering thoses facts :
The game is written in HTML 5 but i may port it to other languages (Android as an example). I can't do that if i use WebSockets because i would have to get additionnals librairies to handle this and i don't want to invest more time in it. So i will focus on HTML 5 for now but porting it is alway an option.
Its a turn-based game so yeah XmlHttpRequest seem to be suitable for this task but at which point ? If i have over 1000 connections sending requests will it be able to support it ? Each turn is an unique request but chat messages is also a request and private messages too, getting player data too (before you join any game) etc. An advantage over WebSockets is that Http Get are easy to make and is supported easily on many platforms so i could obviously go the Android route if i choose this.
I don't want to invest more time in others technologies than thoses stated here.
PubNub cost money in the end but it is very efficient for pushing messages so not using it might be risky and would force me to do the messages relaying code myself.
So here my 4 plans.
Going with WebSockets and use Alchemy as a WebSocketServer for C# which i tested and work wonderfully and still have the PubNub actor in the backend for relaying my messages.
Go with XmlHttpRequests and use a simple WebAPI for the request Gateway.
Go with both. Make the client independent on which technology to choose. Use XmlHttpRequest as a fallback and make the server support both connection. PubNub will still be the relaying actor here which should make the whole stuff communicating.
Go with WebSockets but without PubNub.
So which route do you recommand me to go and why ?
Thanks!
PubNub for Indie Games and Multiplayer Online Worlds
Networking is hard when you are building a simulated world for people to explore. These simulations are often considered. PubNub is the best solution for indie game developers for all the good reasons. Enable Networking in your Indie Game is simple with PubNub's two easy functions PUBNUB.publish({...}) and PUBNUB.subscribe({...}). Adding Networking in your apps allows you to implement multiplayer games and more! Implement real-time notifications between HTML5 browsers, phones, tablets and more. Everything can send and receive data from everywhere on Earth.
WebSockets or XMLHttpRequest or both?
PubNub makes this choice for you, automatically detecting the best connection type suited for your player's systems and capabilities. That means your Indie Game will function as expected on all platforms including Android, iPhone, Chrome / Firefox / IE and more. That makes it easy, so you don't need to worry about transports or delivery methods to the diverse number of platforms that exist. Your team only needs to focus on making a compelling and engaging online multiplayer game.
Online Indie Game - Server Logic
You need a way to securely collect player progress and track actions and consequences on your world. You may also need to track inventory and player state. There are two great services for this.
RoarEngine
First let me recommend http://www.roarengine.com/ RoarEngine an online hosted Game Engine which gives you a Scripting Engine to Unleash your creativity with limitless possibilities by writing your own custom logic. Events, challenges, timed mechanics, you name it. RoarEngine also offers Items & Gifts economy to Shape player interactions by creating items that affect player state, powered by a full featured shop, currency and gifting system that can be managed on the fly.
Parse
I highly recommend https://parse.com/ an online cloud hosted service which managers you user/player sessions. Parse is great when you need an online platform for more abstract and less tailored to gaming; which allows you to define models and objects in the way you choose. With Parse you don't need to focus on building infrastructure, you instead get to focus on building your game world state.
PubNub HTML5 MMO XKCD Game Multiplayer
We wanted to demonstrate the capabilities of HTML5 Indie Games used together with PubNub to enable expansive gameplay that joins players all across the world in real-time. This game uses HTML5 Canvas with multiple users flying around with a balloon figure. If you got stuck, you can click your balloon guy and turn into a ghost to seamlessly move through the landscape unhindered by mortal barriers like trees and hills. There was a problem however with the scaling of users on ordinary off-the-shelf gaming servers. The max concurrency could only be a few users at a time leaving many wonder where the MMO part of the MMO was. PubNub makes this automatic and at a lower cost compared to self-hosting options. Teams who are considering self-hosted options will consider the cost compared to maintaining and hosting a networking cluster for gameplay.
PLAY LIVE - http://www.pubnub.com/static/pubnub-xkcd/index.html
BLOG - http://blog.pubnub.com/xkcd-mmo-websocket-scaling-with-pubnub/
SOURCE CODE - https://github.com/pubnub/pubnub-xkcd
The links above show you a live HTML5 Canvas based game that is powered by PubNub multiplayer capabilities.
Take a look at http://realtime.co - Its a Realtime platform similar to PubNub and with more capabilities.

Resources