No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



The goal for bitbreeds-webrtc is to eventually make a simple Java peer for talking directly to one or several browsers or other WebRTC peers through an unordered/unreliable or unordered/reliable DataChannel.

At the moment the goal is to only allow it to be used as the "server" (the browser must initiate the WebRTC connection), though extending it to be able to act as a "client" (active side) should not be that hard, but it is not something I am interested in writing, since I do not need it at this moment.


bitbreeds webrtc is experimental and not even close to complete and not ready for any kind serious use.

How to run

Run locally.

Main class com.bitbreeds.webrtc.example.DatachannelServer will start a server on port 8443 accepting websocket connections.

Then run ./web/index.html in firefox to connect to the server, share candicates and using WebRTC. If it works it should say ONMESSAGE

Run on a server

If you build webrtc-example, you can start the webrtc-example--.jar like this (make sure you point -Dcom.bitbreeds.keystore to a keystore that exists):

Using the default keystore in src/resources. ONLY FOR TESTING.

java -jar -Dcom.bitbreeds.keystore="../src/main/resources/ws2.jks" webrtc-example-1.0-SNAPSHOT-capsule.jar
java -Dcom.bitbreeds.keystore=path-to-your-keystore -Dcom.bitbreeds.keystore.alias=your-key-alias -Dcom.bitbreeds.keystore.pass=your-key-pass -Dcom.bitbreeds.ip="" -jar webrtc-example-1.0-SNAPSHOT-capsule.jar

If the server has problems finding its own public IP address, you can supply the IP address like this.


This might be needed since you must send a candidate to the other peer.

The keystore parameters are pretty self explanatory:


Setting up a webrtc datachannel echoing input

Remember to provide your own keystore, the keystores provided here are for testing

SimplePeerServer peerConnectionServer = new SimplePeerServer(new KeystoreInfo("path","alias","password"));

peerConnectionServer.onConnection = (connection) -> {

        connection.onDataChannel = (dataChannel) -> {

            dataChannel.onOpen = (ev) -> {

            dataChannel.onMessage = (ev) -> {
                String in = new String(ev.getData());
                dataChannel.send("echo-" + in);

            dataChannel.onClose = (ev) -> {

            dataChannel.onError = (ev) -> {


Run a complete selenium test

class Browser<Chrome/Firefox>*Test runs a full test against a browser. It will start the server, open the browser and connect. Then end once it has opened the WebRTC connection, or sent a bunch of messages over the peerconnection.


To start firefox with logging (this might be outdated), take a look in ./

dat=`echo ~`
echo $path
export WEBRTC_TRACE_FILE=$trace
export MOZ_LOG_FILE=$path
export MOZ_LOG='timestamp,sync,jsep:5,rtplogger:5,SCTP:5,signaling:5,mtransport:5,MediaManager:5,webrtc_trace:5'
export R_LOG_LEVEL=9
export R_LOG_VERBOSE=1
open /Applications/

That log will contain a lot of information needed to debug eventual issues. On the server side setting levels in logback-test.xml control logging.

Chrome also has chrome://webrtc-internals, which is great for debugging.