All Projects → ambianic → peerjs-python

ambianic / peerjs-python

Licence: Apache-2.0 License
Python port of PeerJS client

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to peerjs-python

Laverna
Laverna is a JavaScript note taking application with Markdown editor and encryption support. Consider it like open source alternative to Evernote.
Stars: ✭ 8,770 (+15560.71%)
Mutual labels:  webrtc, peer-to-peer
Stun
A Go implementation of STUN
Stars: ✭ 141 (+151.79%)
Mutual labels:  webrtc, peer-to-peer
Rn Voice Video Call
Usage of WebRTC for voice & video call with peer-to-peer or conference with Login and Register screen using response & Async storage with Call Dis/Connect, Failed and Idle views in react native. Youtube:
Stars: ✭ 100 (+78.57%)
Mutual labels:  webrtc, peer-to-peer
Hyperhost
P2P Node Servers in the Browser
Stars: ✭ 46 (-17.86%)
Mutual labels:  webrtc, peer-to-peer
Pikachu Volleyball P2p Online
Pikachu Volleyball peer-to-peer online via WebRTC data channels
Stars: ✭ 160 (+185.71%)
Mutual labels:  webrtc, peer-to-peer
Camus
Peer-to-peer group video chat using WebRTC, Python, and Javascript
Stars: ✭ 75 (+33.93%)
Mutual labels:  webrtc, peer-to-peer
Ice
A Go implementation of ICE
Stars: ✭ 114 (+103.57%)
Mutual labels:  webrtc, peer-to-peer
Sharedrop
Easy P2P file transfer powered by WebRTC - inspired by Apple AirDrop
Stars: ✭ 5,222 (+9225%)
Mutual labels:  webrtc, peer-to-peer
P2p Cdn Sdk Javascript
Free p2p cdn github javascript sdk to reduce video streaming costs of live and on demand video using webrtc by upto 90% and improve scalability by 6x - 🚀 Vadootv 🚀
Stars: ✭ 158 (+182.14%)
Mutual labels:  webrtc, peer-to-peer
Wt Tracker
High-performance WebTorrent tracker
Stars: ✭ 144 (+157.14%)
Mutual labels:  webrtc, peer-to-peer
Peer Calls
Group peer to peer video calls for everyone written in Go and TypeScript
Stars: ✭ 837 (+1394.64%)
Mutual labels:  webrtc, peer-to-peer
Video Meeting
Google Meet / Zoom clone in a few lines of code
Stars: ✭ 187 (+233.93%)
Mutual labels:  webrtc, peer-to-peer
Uproxy P2p
Internet without borders
Stars: ✭ 798 (+1325%)
Mutual labels:  webrtc, peer-to-peer
Laplace
Laplace is an open-source project to enable screen sharing directly via browser. Based on WebRTC for low latency peer-to-peer connections, and WebSocket implemented in golang for signaling.
Stars: ✭ 81 (+44.64%)
Mutual labels:  webrtc, peer-to-peer
Gfile
Direct file transfer over WebRTC
Stars: ✭ 598 (+967.86%)
Mutual labels:  webrtc, peer-to-peer
Netsix
Netsix allows you to share videos with your friends in a real peer-to-peer manner using WebRTC.
Stars: ✭ 113 (+101.79%)
Mutual labels:  webrtc, peer-to-peer
Decentralized Video Chat
🚀 Zipcall- Acquired @ 250k users 🚀 Peer to peer browser video calling platform with unmatched video quality and latency.
Stars: ✭ 3,284 (+5764.29%)
Mutual labels:  webrtc, peer-to-peer
Libdatachannel
C/C++ WebRTC Data Channels and Media Transport standalone library
Stars: ✭ 336 (+500%)
Mutual labels:  webrtc, peer-to-peer
Nile.js
Server
Stars: ✭ 1,757 (+3037.5%)
Mutual labels:  webrtc, peer-to-peer
Trango Self Hosted
Host trango and communicate with those around you without the internet!
Stars: ✭ 164 (+192.86%)
Mutual labels:  webrtc, peer-to-peer

Gitpod ready-to-code

peerjs-python

Python port of PeerJS client.

  • Tracked in issue #160 of the official PeerJS project.

Enables Progressive Web Apps to discover and pair directly with Python apps using secure, browser supported WebRTC protocol.

Additional features:

  • HTTP Proxy over WebRTC data channel. It allows PeerJS browser clients to make remote REST requests over WebRTC to a local REST API running behind a firewall.
  • Plug-and-play functionality that allows seamless Airdrop-like pairing between peers running on the same local network.

See Ambianic UI PNP module for a real-world example how PeerJS Python is used with PnP and HTTP Proxy.

Dependencies

Uses aiortc as Python WebRTC provider. This requires installing a few native dependencies for audio/video media processing.

On Debian/Ubuntu run:

apt install libavdevice-dev libavfilter-dev libopus-dev libvpx-dev pkg-config libsrtp2-dev

On OS X run:

brew install ffmpeg opus libvpx pkg-config

Motivation

This project was originally motivated while searching for a way to:

  • Connect a Progressive Web App (Ambianic UI) directly and securely to an edge device (Ambianic Edge) running Python app on a Raspberry Pi behind a home Internet router.

This article in WebRTCHacks provides more insight into the background of this project.

Main requirements

  • Easy Airdrop-like plug and play discovery and pairing between web app and edge devices.
  • Direct peer-to-peer connectivity to minimize:
    • latency
    • architecture complexity
    • costs associated with traffic and hosting of tunneling servers
    • exposure to public server security attacks
  • Support for:
    • Secure connections
    • Bi-directional data-channel
    • Low latency audio/video media streaming
    • Bi-directional live audio/video media
  • Rely only on standard broadly supported web browser features.
    • Stable mobile device support (iOS, Android, Raspberry Pi)
    • Stable desktop OS support (Windows, Mac OS, Linux)
    • No need for browser plug-ins
  • No intermediary cloud service providers to store and sync user data.
  • No tedious and complicated NAT setups of dynamic DNS with SSH tunnels between public IP servers and edge devices behind firewall.
  • High throughput and scalability via lightweight signaling service without a persistence layer.

Project Status

Initial working prototype completed. PeerJS Python is now able to connect over WebRTC DataChannel to PeerJS in the browser and exchange messages.

  • Complete and test connectivity with signaling server (peerjs-server).
  • Complete and test data channel connectivity with web app peers.
  • Release initial version to PyPi.
  • support for python 3.7 & python 3.8
  • support for python 3.9 (see dependency issue)
  • >90% code coverage with CI tests.
  • Port media support.

Code Examples

A typical p2p session takes these steps:

  1. Establish signaling server session that enables peers to discover each other.
  2. Discover remote peer ID (either via signaling server room affinity or other means)
  3. Request connection to remote peer via signaling server
  4. Connect to remote peer via WebRTC ICE protocol.
  5. Exchange data or media with remote peer over p2p WebRTC connection.

The following code snippet shows the initial part of establishing a signaling server connection.

    options = PeerOptions(
        host=config['host'],
        port=config['port'],
        secure=config['secure'],
        token=new_token,
        config=RTCConfiguration(
            iceServers=[RTCIceServer(**srv) for srv in config['ice_servers']]
        )
    )
    peer = Peer(id=savedPeerId, peer_options=options)
    await peer.start()
    log.info('peer activated')
    _setPnPServiceConnectionHandlers(peer)

Once a signaling server connection is established, a peer can request connection to another peer or listen for requests from a remote peer. The example snippet bellow shows the latter:

    @peer.on(PeerEventType.Connection)
    async def peer_connection(peerConnection):
        log.info('Remote peer trying to establish connection')
        _setPeerConnectionHandlers(peerConnection)

After a p2p connection is established, a peer can receive and send application messages. The following snippet shows how a peer receives a message:

    @peerConnection.on(ConnectionEventType.Data)
    async def pc_data(data):
        log.debug('data received from remote peer \n%r', data)

For a complete working example see this file.

Other Related Open Source projects

There are several great projects that solve the problem of accessing IoT devices behind firewall via tunneling servers.

  • Python Proxy: Asynchronous tunnel proxy implemented in Python 3 asyncio.
  • Proxy.py: HTTP proxy server written in Python.
  • Inlets: Reverse proxy and service tunnel written in Go.
  • Macchina.io: IoT tunneling proxy written in C++.

A few popular p2p projects that use WebRTC:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].