Code Monkey home page Code Monkey logo

peerjs-python's Introduction

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:

peerjs-python's People

Contributors

abdallahalhaddad avatar amotl avatar dependabot-preview[bot] avatar dependabot[bot] avatar espeed avatar ivelin avatar muka avatar multu avatar semantic-release-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

peerjs-python's Issues

Improve http proxy over webrtc

  • Support http status codes.
  • Support large files over http.
  • Support http2 style server push. Lower priority since webrtc is bi-directional already.

Runtime Error: PeerID is taken

Occasionally peerjs goes into a loop that prevents it from registering an existing peerid with the pnp signaling server.

ambianic-edge    | 2021-01-15 03:00:36 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:36 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:36 INFO /workspace/peerjs/ext/http-proxy.py.peer_close(124): Peer connection closed
ambianic-edge    | 2021-01-15 03:00:36 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 455.79 ms, 1.24 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:36 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:36 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:36 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:36 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:36 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:36 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:36 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:36 ERROR /usr/lib/python3.7/asyncio/base_events.py.default_exception_handler(1608): Exception in callback AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55
ambianic-edge    | handle: <Handle AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55>
ambianic-edge    | Traceback (most recent call last):
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py", line 62, in _callback
ambianic-edge    |     self.emit('error', exc)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 116, in emit
ambianic-edge    |     self._emit_handle_potential_error(event, args[0] if args else None)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 86, in _emit_handle_potential_error
ambianic-edge    |     raise error
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 119, in peer_disconnected
ambianic-edge    |     await peer.reconnect()
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 537, in reconnect
ambianic-edge    |     raise RuntimeError("This peer cannot reconnect to the server. "
ambianic-edge    | RuntimeError: This peer cannot reconnect to the server. It has already been destroyed.
ambianic-edge    | 2021-01-15 03:00:37 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(240): No pose with key-points found.
ambianic-edge    | 2021-01-15 03:00:37 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 488.77 ms, 1.10 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:38 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 452.15 ms, 1.24 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:38 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 643.56 ms, 0.36 fps in pipeline entry_area_watch
ambianic-edge    | 2021-01-15 03:00:38 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.process_sample(57): FallDetector received new sample
ambianic-edge    | 2021-01-15 03:00:38 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(227): Calling TF engine for inference
ambianic-edge    | 2021-01-15 03:00:38 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 450.00 ms, 1.24 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.make_discoverable(274): Peer destroyed. Will create a new peer.
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(239): creating peer
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(244): last saved savedPeerId cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(246): Peer session token b78f2565-05ad-4dbb-aee0-183d6650dbab
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(256): pnpService: peer created with id cba72289-e3e4-43dd-9770-81b568655f67 , options: PeerOptions(host='ambianic-pnp.herokuapp.com', port=443, path='/', key='peerjs', token='b78f2565-05ad-4dbb-aee0-183d6650dbab', config=RTCConfiguration(iceServers=[RTCIceServer(urls=['stun:stun.l.google.com:19302'], username=None, credential=None, credentialType='password')]), secure=True, pingInterval=5)
ambianic-edge    | 2021-01-15 03:00:39 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(258): peer activated
ambianic-edge    | 2021-01-15 03:00:39 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:39 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:39 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:39 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:39 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.peer_close(124): Peer connection closed
ambianic-edge    | 2021-01-15 03:00:39 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:39 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:39 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:39 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:39 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:39 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:39 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 465.86 ms, 1.21 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:39 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:39 ERROR /usr/lib/python3.7/asyncio/base_events.py.default_exception_handler(1608): Exception in callback AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55
ambianic-edge    | handle: <Handle AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55>
ambianic-edge    | Traceback (most recent call last):
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py", line 62, in _callback
ambianic-edge    |     self.emit('error', exc)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 116, in emit
ambianic-edge    |     self._emit_handle_potential_error(event, args[0] if args else None)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 86, in _emit_handle_potential_error
ambianic-edge    |     raise error
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 119, in peer_disconnected
ambianic-edge    |     await peer.reconnect()
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 537, in reconnect
ambianic-edge    |     raise RuntimeError("This peer cannot reconnect to the server. "
ambianic-edge    | RuntimeError: This peer cannot reconnect to the server. It has already been destroyed.
ambianic-edge    | 2021-01-15 03:00:39 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(240): No pose with key-points found.
ambianic-edge    | 2021-01-15 03:00:40 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 449.59 ms, 1.23 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:41 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 674.23 ms, 0.37 fps in pipeline entry_area_watch
ambianic-edge    | 2021-01-15 03:00:41 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.process_sample(57): FallDetector received new sample
ambianic-edge    | 2021-01-15 03:00:41 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(227): Calling TF engine for inference
ambianic-edge    | 2021-01-15 03:00:41 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 507.75 ms, 1.22 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:42 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 462.90 ms, 1.34 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:42 INFO /workspace/peerjs/ext/http-proxy.py.make_discoverable(274): Peer destroyed. Will create a new peer.
ambianic-edge    | 2021-01-15 03:00:42 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(239): creating peer
ambianic-edge    | 2021-01-15 03:00:42 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(244): last saved savedPeerId cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:42 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(246): Peer session token 16c14cf8-2403-40b1-86c9-bb8b139f99f2
ambianic-edge    | 2021-01-15 03:00:42 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(256): pnpService: peer created with id cba72289-e3e4-43dd-9770-81b568655f67 , options: PeerOptions(host='ambianic-pnp.herokuapp.com', port=443, path='/', key='peerjs', token='16c14cf8-2403-40b1-86c9-bb8b139f99f2', config=RTCConfiguration(iceServers=[RTCIceServer(urls=['stun:stun.l.google.com:19302'], username=None, credential=None, credentialType='password')]), secure=True, pingInterval=5)
ambianic-edge    | 2021-01-15 03:00:42 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(240): No pose with key-points found.
ambianic-edge    | 2021-01-15 03:00:42 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:42 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(258): peer activated
ambianic-edge    | 2021-01-15 03:00:42 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:42 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:42 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:42 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:42 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:42 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:42 INFO /workspace/peerjs/ext/http-proxy.py.peer_close(124): Peer connection closed
ambianic-edge    | 2021-01-15 03:00:42 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 454.93 ms, 1.25 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:42 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:42 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:42 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:42 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:42 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:42 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:43 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:43 ERROR /usr/lib/python3.7/asyncio/base_events.py.default_exception_handler(1608): Exception in callback AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55
ambianic-edge    | handle: <Handle AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55>
ambianic-edge    | Traceback (most recent call last):
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py", line 62, in _callback
ambianic-edge    |     self.emit('error', exc)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 116, in emit
ambianic-edge    |     self._emit_handle_potential_error(event, args[0] if args else None)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 86, in _emit_handle_potential_error
ambianic-edge    |     raise error
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 119, in peer_disconnected
ambianic-edge    |     await peer.reconnect()
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 537, in reconnect
ambianic-edge    |     raise RuntimeError("This peer cannot reconnect to the server. "
ambianic-edge    | RuntimeError: This peer cannot reconnect to the server. It has already been destroyed.
ambianic-edge    | 2021-01-15 03:00:43 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 627.10 ms, 0.37 fps in pipeline entry_area_watch
ambianic-edge    | 2021-01-15 03:00:43 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.process_sample(57): FallDetector received new sample
ambianic-edge    | 2021-01-15 03:00:43 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(227): Calling TF engine for inference
ambianic-edge    | 2021-01-15 03:00:43 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 444.11 ms, 1.15 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:44 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 470.36 ms, 1.12 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:45 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(240): No pose with key-points found.
ambianic-edge    | 2021-01-15 03:00:45 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 487.18 ms, 1.27 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:45 INFO /workspace/peerjs/ext/http-proxy.py.make_discoverable(274): Peer destroyed. Will create a new peer.
ambianic-edge    | 2021-01-15 03:00:45 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(239): creating peer
ambianic-edge    | 2021-01-15 03:00:45 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(244): last saved savedPeerId cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:45 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(246): Peer session token 1af3ef29-1a61-4b76-9912-a63f71f47459
ambianic-edge    | 2021-01-15 03:00:45 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(256): pnpService: peer created with id cba72289-e3e4-43dd-9770-81b568655f67 , options: PeerOptions(host='ambianic-pnp.herokuapp.com', port=443, path='/', key='peerjs', token='1af3ef29-1a61-4b76-9912-a63f71f47459', config=RTCConfiguration(iceServers=[RTCIceServer(urls=['stun:stun.l.google.com:19302'], username=None, credential=None, credentialType='password')]), secure=True, pingInterval=5)
ambianic-edge    | 2021-01-15 03:00:45 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:45 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(258): peer activated
ambianic-edge    | 2021-01-15 03:00:45 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:45 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:45 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:45 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:45 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:45 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:45 INFO /workspace/peerjs/ext/http-proxy.py.peer_close(124): Peer connection closed
ambianic-edge    | 2021-01-15 03:00:46 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:46 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:46 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:46 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:46 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:46 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:46 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:46 ERROR /usr/lib/python3.7/asyncio/base_events.py.default_exception_handler(1608): Exception in callback AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55
ambianic-edge    | handle: <Handle AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55>
ambianic-edge    | Traceback (most recent call last):
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py", line 62, in _callback
ambianic-edge    |     self.emit('error', exc)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 116, in emit
ambianic-edge    |     self._emit_handle_potential_error(event, args[0] if args else None)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 86, in _emit_handle_potential_error
ambianic-edge    |     raise error
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 119, in peer_disconnected
ambianic-edge    |     await peer.reconnect()
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 537, in reconnect
ambianic-edge    |     raise RuntimeError("This peer cannot reconnect to the server. "
ambianic-edge    | RuntimeError: This peer cannot reconnect to the server. It has already been destroyed.
ambianic-edge    | 2021-01-15 03:00:46 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 498.90 ms, 1.25 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:46 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 690.43 ms, 0.35 fps in pipeline entry_area_watch
ambianic-edge    | 2021-01-15 03:00:46 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.process_sample(57): FallDetector received new sample
ambianic-edge    | 2021-01-15 03:00:46 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(227): Calling TF engine for inference
ambianic-edge    | 2021-01-15 03:00:47 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 462.33 ms, 1.30 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:47 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 497.38 ms, 1.14 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:48 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(240): No pose with key-points found.
ambianic-edge    | 2021-01-15 03:00:48 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 459.68 ms, 1.23 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:48 INFO /workspace/peerjs/ext/http-proxy.py.make_discoverable(274): Peer destroyed. Will create a new peer.
ambianic-edge    | 2021-01-15 03:00:48 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(239): creating peer
ambianic-edge    | 2021-01-15 03:00:48 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(244): last saved savedPeerId cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:48 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(246): Peer session token e00575ca-df54-48b4-8938-b7e438ceb796
ambianic-edge    | 2021-01-15 03:00:48 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(256): pnpService: peer created with id cba72289-e3e4-43dd-9770-81b568655f67 , options: PeerOptions(host='ambianic-pnp.herokuapp.com', port=443, path='/', key='peerjs', token='e00575ca-df54-48b4-8938-b7e438ceb796', config=RTCConfiguration(iceServers=[RTCIceServer(urls=['stun:stun.l.google.com:19302'], username=None, credential=None, credentialType='password')]), secure=True, pingInterval=5)
ambianic-edge    | 2021-01-15 03:00:49 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:49 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(258): peer activated
ambianic-edge    | 2021-01-15 03:00:49 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:49 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:49 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:49 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:49 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:49 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:49 INFO /workspace/peerjs/ext/http-proxy.py.peer_close(124): Peer connection closed
ambianic-edge    | 2021-01-15 03:00:49 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 663.05 ms, 0.37 fps in pipeline entry_area_watch
ambianic-edge    | 2021-01-15 03:00:49 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.process_sample(57): FallDetector received new sample
ambianic-edge    | 2021-01-15 03:00:49 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(227): Calling TF engine for inference
ambianic-edge    | 2021-01-15 03:00:49 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:49 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:49 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:49 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:49 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2021-01-15 03:00:49 WARNING /workspace/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2021-01-15 03:00:49 INFO /workspace/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer cba72289-e3e4-43dd-9770-81b568655f67 disconnected from server.
ambianic-edge    | 2021-01-15 03:00:49 ERROR /usr/lib/python3.7/asyncio/base_events.py.default_exception_handler(1608): Exception in callback AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55
ambianic-edge    | handle: <Handle AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55>
ambianic-edge    | Traceback (most recent call last):
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py", line 62, in _callback
ambianic-edge    |     self.emit('error', exc)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 116, in emit
ambianic-edge    |     self._emit_handle_potential_error(event, args[0] if args else None)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 86, in _emit_handle_potential_error
ambianic-edge    |     raise error
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 119, in peer_disconnected
ambianic-edge    |     await peer.reconnect()
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 537, in reconnect
ambianic-edge    |     raise RuntimeError("This peer cannot reconnect to the server. "
ambianic-edge    | RuntimeError: This peer cannot reconnect to the server. It has already been destroyed.
ambianic-edge    | 2021-01-15 03:00:49 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 556.68 ms, 1.11 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:50 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 447.27 ms, 1.25 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:50 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(240): No pose with key-points found.
ambianic-edge    | 2021-01-15 03:00:51 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 465.34 ms, 1.14 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:51 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 624.98 ms, 0.37 fps in pipeline entry_area_watch
ambianic-edge    | 2021-01-15 03:00:51 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.process_sample(57): FallDetector received new sample
ambianic-edge    | 2021-01-15 03:00:51 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/fall_detect.py.fall_detect(227): Calling TF engine for inference
ambianic-edge    | 2021-01-15 03:00:52 INFO /workspace/peerjs/ext/http-proxy.py.make_discoverable(274): Peer destroyed. Will create a new peer.
ambianic-edge    | 2021-01-15 03:00:52 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(239): creating peer
ambianic-edge    | 2021-01-15 03:00:52 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(244): last saved savedPeerId cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:52 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(246): Peer session token d0ac6155-dddc-4e9e-9d56-f7d29e42f01a
ambianic-edge    | 2021-01-15 03:00:52 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(256): pnpService: peer created with id cba72289-e3e4-43dd-9770-81b568655f67 , options: PeerOptions(host='ambianic-pnp.herokuapp.com', port=443, path='/', key='peerjs', token='d0ac6155-dddc-4e9e-9d56-f7d29e42f01a', config=RTCConfiguration(iceServers=[RTCIceServer(urls=['stun:stun.l.google.com:19302'], username=None, credential=None, credentialType='password')]), secure=True, pingInterval=5)
ambianic-edge    | 2021-01-15 03:00:52 INFO /opt/ambianic-edge/src/ambianic/pipeline/ai/image_detection.py.log_stats(200): ObjectDetector inference time 458.99 ms, 1.14 fps in pipeline front_door_watch
ambianic-edge    | 2021-01-15 03:00:52 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: cba72289-e3e4-43dd-9770-81b568655f67
ambianic-edge    | 2021-01-15 03:00:52 INFO /workspace/peerjs/ext/http-proxy.py.pnp_service_connect(258): peer activated
ambianic-edge    | 2021-01-15 03:00:52 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/workspace/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2021-01-15 03:00:52 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:52 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | 2021-01-15 03:00:52 ERROR /workspace/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$cba72289-e3e4-43dd-9770-81b568655f67" is taken
ambianic-edge    | NoneType: None

Required version of python and libraries?

First of all I would like to thank you for your effort in porting peerjs to python, this is a very interesting library!

Running the code below gives me:
createDataChannel() got an unexpected keyword argument 'ordered' File "/home/pi/automations/OpenCv/lib/python3.7/site-packages/peerjs/negotiator.py", line 63, in startConnection dataConnection.label, ordered=reliable)

options = PeerOptions(
    host = HOST,
    port = PORT,
    path = PATH,
    secure = True
)

peer = Peer("myId", options)
@peer.on(PeerEventType.Open)
async def on_open(data):
    print("Open: " + data)

async def start():
    global peer
    await peer.start()
    remote = await peer.connect("remoteId")
    while True:#peer.open:
        await asyncio.sleep(3)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(start())
    loop.run_forever()

However, removing the 'ordered' argument, gives me further exceptions, like:
'dict' object has no attribute 'constraints'
(from negotiator.py #209)

So I guess that the problem might be in my python version or the installed library versions...(?)
I installed these requirements in a new venv:
#requirements.txt av~=8.0.0 aiortc>=0.9 websockets>=8.1 aiohttp>=3.6 pyee>=6.0 websockets>=8.1 dataclasses_json>=0.3 coloredlogs>=10.0

python --version Python 3.7.3

Could you please help to come around the problems?

Documentation

Is there any documentation for this? I'm fairly new to WebRTC

Intermittent errors connecting to signaling server

ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.make_discoverable(274): Peer destroyed. Will create a new peer.
ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.pnp_service_connect(239): creating peer
ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.pnp_service_connect(244): last saved savedPeerId c559151b-eb8d-468a-91b0-7db3baf25dd2
ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.pnp_service_connect(246): Peer session token 9a515af4-8c7d-4a09-80af-b188e8770407
ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.pnp_service_connect(256): pnpService: peer created with id c559151b-eb8d-468a-91b0-7db3baf25dd2 , options: PeerOptions(host='ambianic-pnp.herokuapp.com', port=443, path='/', key='peerjs', token='9a515af4-8c7d-4a09-80af-b188e8770407', config=RTCConfiguration(iceServers=[RTCIceServer(urls=['stun:stun1.l.google.com:19302', 'stun:stun2.l.google.com:19302', 'stun:stun3.l.google.com:19302', 'stun:stun4.l.google.com:19302', 'stun:stun.l.google.com:19302', 'stun:stun.services.mozilla.com:3478', 'stun:stunserver.org:3478'], username=None, credential=None, credentialType='password'), RTCIceServer(urls=['turn:numb.viagenie.ca'], username='[email protected]', credential='muazkh', credentialType='password'), RTCIceServer(urls=['turn:192.158.29.39:3478?transport=udp'], username='28224511:1379330808', credential='JZEOEt2V3Qb0y27GRntt2u2PAYA=', credentialType='password'), RTCIceServer(urls=['turn:192.158.29.39:3478?transport=tcp'], username='28224511:1379330808', credential='JZEOEt2V3Qb0y27GRntt2u2PAYA=', credentialType='password'), RTCIceServer(urls=['turn:turn.bistri.com:80'], username='homeo', credential='homeo', credentialType='password'), RTCIceServer(urls=['turn:turn.anyfirewall.com:443?transport=tcp'], username='webrtc', credential='webrtc', credentialType='password'), RTCIceServer(urls=['turn:0.peerjs.com:3478'], username='peerjs', credential='peerjsp', credentialType='password')]), secure=True, pingInterval=5)
ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.start(118): Peer started with UUID: c559151b-eb8d-468a-91b0-7db3baf25dd2
ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.pnp_service_connect(258): peer activated
ambianic-edge    | 2020-05-21 23:30:06 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/peer.py._abort(454): Aborting! 
ambianic-edge    | PeerErrorType: PeerErrorType.UnavailableID 
ambianic-edge    | Error message: ID "$c559151b-eb8d-468a-91b0-7db3baf25dd2" is taken
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
ambianic-edge    |     "__main__", mod_spec)
ambianic-edge    |   File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
ambianic-edge    |     exec(code, run_globals)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py", line 362, in <module>
ambianic-edge    |     loop.run_until_complete(_start())
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
ambianic-edge    |     self.run_forever()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
ambianic-edge    |     self._run_once()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
ambianic-edge    |     handle._run()
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 231, in _on_server_idtaken
ambianic-edge    |     f'ID "${self.id}" is taken')
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 455, in _abort
ambianic-edge    |     traceback.print_stack()
ambianic-edge    | 2020-05-21 23:30:06 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(464): Connection error: ID "$c559151b-eb8d-468a-91b0-7db3baf25dd2" is taken
ambianic-edge    | 2020-05-21 23:30:06 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/peer.py.emitError(469): Connection error: 
ambianic-edge    | ID "$c559151b-eb8d-468a-91b0-7db3baf25dd2" is taken
ambianic-edge    | 2020-05-21 23:30:06 ERROR /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.peer_error(128): Peer error ID "$c559151b-eb8d-468a-91b0-7db3baf25dd2" is taken
ambianic-edge    | NoneType: None
ambianic-edge    | 2020-05-21 23:30:06 WARNING /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.peer_error(129): peerConnectionStatus None
ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.peer_close(124): Peer connection closed
ambianic-edge    | 2020-05-21 23:30:06 INFO /usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py.peer_disconnected(110): Peer c559151b-eb8d-468a-91b0-7db3baf25dd2 disconnected from server.
ambianic-edge    | 2020-05-21 23:30:06 ERROR /usr/lib/python3.7/asyncio/base_events.py.default_exception_handler(1608): Exception in callback AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55
ambianic-edge    | handle: <Handle AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe... destroyed.')>) at /usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py:55>
ambianic-edge    | Traceback (most recent call last):
ambianic-edge    |   File "/usr/lib/python3.7/asyncio/events.py", line 88, in _run
ambianic-edge    |     self._context.run(self._callback, *self._args)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_asyncio.py", line 62, in _callback
ambianic-edge    |     self.emit('error', exc)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 111, in emit
ambianic-edge    |     self._emit_handle_potential_error(event, args[0] if args else None)
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/pyee/_base.py", line 83, in _emit_handle_potential_error
ambianic-edge    |     raise error
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/ext/http-proxy.py", line 119, in peer_disconnected
ambianic-edge    |     await peer.reconnect()
ambianic-edge    |   File "/usr/local/lib/python3.7/dist-packages/peerjs/peer.py", line 537, in reconnect
ambianic-edge    |     raise RuntimeError("This peer cannot reconnect to the server. "
ambianic-edge    | RuntimeError: This peer cannot reconnect to the server. It has already been destroyed.
^CERROR: Aborting.

Move ICE server config outside of python code to a config file

Currently ICE server config resides in util.py

It would be more convenient for users to edit ICE settings if they are in a separate and documented config file, e.g. webrtc-config.yaml

This is the section that can be moved:

RTCConfiguration(
    iceServers=[
        RTCIceServer(
            urls=[
                "stun:stun1.l.google.com:19302",
                "stun:stun2.l.google.com:19302",
                "stun:stun3.l.google.com:19302",
                "stun:stun4.l.google.com:19302",
                "stun:stun.l.google.com:19302",
                "stun:stun.services.mozilla.com:3478",
                "stun:stunserver.org:3478",
                ]
                ),
        RTCIceServer(
            urls=['turn:numb.viagenie.ca'],
            username='[email protected]',
            credential='muazkh'
            ),
        RTCIceServer(
            urls=['turn:192.158.29.39:3478?transport=udp'],
            credential='JZEOEt2V3Qb0y27GRntt2u2PAYA=',
            username='28224511:1379330808'
            ),
        RTCIceServer(
            urls=['turn:192.158.29.39:3478?transport=tcp'],
            credential='JZEOEt2V3Qb0y27GRntt2u2PAYA=',
            username='28224511:1379330808'
            ),
        RTCIceServer(
            urls=['turn:turn.bistri.com:80'],
            credential='homeo',
            username='homeo'
            ),
        RTCIceServer(
            urls=['turn:turn.anyfirewall.com:443?transport=tcp'],
            credential='webrtc',
            username='webrtc'
            ),
        RTCIceServer(
            urls=["turn:0.peerjs.com:3478"],
            username="peerjs",
            credential="peerjsp"
            )
        ]
    )

Implement ICE server probing to prevent webrtc service downtime

Currently aiortc does not implement ICETrickle nor is it able to fall back from a failing primary STUN or TURN server to a fall back option provided in the API standard RTCConfiguration list.

As a workaround, we can implement a background thread that periodically (e.g. every minute) polls the servers in the RTCConfig list and removes the dead ones. Respectively as needed, signal the peerjs code to reconnect via healthy servers.

Binary DataChannel message handling broken

Hello ๐Ÿ‘‹ Thank you for this awesome library! I started working with it yesterday and I noticed that, unless I'm missing something, DataChannel message handling appears to be broken for binary-serialized messages. Every time I receive a binary DataChannel message, I receive the below exception:

2021-01-06 08:49:41 WARNING ~/Development/proj/venv/lib/python3.9/site-packages/peerjs/dataconnection.py._handleDataMessage(171): Unpacking data...
2021-01-06 08:49:41 ERROR /usr/local/Cellar/[email protected]/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py.default_exception_handler(1738): Exception in callback AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe...te 'unpack'")>) at ~/Development/proj/venv/lib/python3.9/site-packages/pyee/_asyncio.py:55
handle: <Handle AsyncIOEventEmitter._emit_run.<locals>._callback(<Task finishe...te 'unpack'")>) at ~/Development/proj/venv/lib/python3.9/site-packages/pyee/_asyncio.py:55>
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.9.1_4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "~/Development/proj/venv/lib/python3.9/site-packages/pyee/_asyncio.py", line 62, in _callback
    self.emit('error', exc)
  File "~/Development/proj/venv/lib/python3.9/site-packages/pyee/_base.py", line 116, in emit
    self._emit_handle_potential_error(event, args[0] if args else None)
  File "~/Development/proj/venv/lib/python3.9/site-packages/pyee/_base.py", line 86, in _emit_handle_potential_error
    raise error
  File "~/Development/proj/venv/lib/python3.9/site-packages/peerjs/dataconnection.py", line 142, in on_datachannel_message
    await self._handleDataMessage(msg)
  File "~/Development/proj/venv/lib/python3.9/site-packages/peerjs/dataconnection.py", line 172, in _handleDataMessage
    deserializedData = util.unpack(data)
AttributeError: 'Util' object has no attribute 'unpack'

This is occurring in the DataConnection class, when the _handleDataMessage function attempts to call util.unpack():

if isinstance(data, bytes):
log.warning('Unpacking data...')
deserializedData = util.unpack(data)

However, the assignment of util.unpack() appears to have been removed in #17 when the msgpack dependency was removed, in order to fix a bug of some sort.

Am I missing something here, or does this functionality not work right now?

Thank you for your time!

Installation on Python 3.9

Hi Ivelin,

as outlined within #46, there are no binary wheels for PyAV on Python 3.9 yet, see [1]. @Odianosen25 observed the same within PyAV-Org/PyAV#697. So, we probably should add a friendly question at [2], asking whether building and uploading binary wheels for Python 3.9 to PyPI would be possible.

Otherwise, people installing peerjs-python will need the complete compiler toolchain plus appropriate header files of ffmpeg and friends on their machines which might not be appropriate for many occasions as the additional build cycle will a) waste resources and b) might take quite a while on lower-end machines like the RaspberryPi or even less powerful ARM-based SBCs.

With kind regards,
Andreas.

[1] https://pypi.org/project/av/#files
[2] https://github.com/PyAV-Org/PyAV/issues

EDIT: I just recognized there are no PyAV wheels for ARM on [1] yet, so please forget about my last comment. However, it might make sense to also ask for them as I discovered that ambianic-box is actually ARM-based, right?

I found that PyAV already uses pibuildwheel and adding building for ARM into the mix will be possible. PyTables/PyTables#823 has many interesting details about this topic.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.