Unwebsockify is a TCP to WebSocket proxy/bridge -- like a reverse websockify.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.7 KiB

2 years ago
  1. Unwebsockify is a TCP to WebSocket proxy/bridge. It accepts a plain
  2. TCP connection and connects to a WebSocket server, effectively adding
  3. WS support to a client that does not natively support it. It is
  4. essentially the opposite of
  5. [websockify](https://github.com/novnc/websockify).
  6. Note that this only handles simple byte streams of data, with no
  7. support for conveying WebSockets message framing back to the client.
  8. In most cases, **specifying the WebSockets subprotocol (via
  9. `--subproto`) is necessary**, because the server expects it to match
  10. some particular string.
  11. # Install dependencies
  12. Using a virtual environment:
  13. python3 -m venv venv
  14. venv/bin/pip install -r requirements.txt
  15. venv/bin/python unwebsockify.py -h
  16. Or use docker (or replace `docker` with `podman`):
  17. docker build -t unwebsockify .
  18. docker run -p 13232:13232 unwebsockify -h
  19. # Usage
  20. usage: unwebsockify.py [-h] [--port PORT] [--listen ADDR] [--subproto SUBPROTO] URL
  21. positional arguments:
  22. URL WebSocket URL (ws://.. or wss://..)
  23. optional arguments:
  24. -h, --help show this help message and exit
  25. --port PORT, -p PORT TCP listen port
  26. --listen ADDR, -l ADDR TCP listen address
  27. --subproto SUBPROTO, -s SUBPROTO WebSocket subprotocol
  28. # Example
  29. Eclipse Mosquitto supports WebSockets on the server side, but not on
  30. the client side (for bridging). To bridge two MQTT instances via
  31. websockets, run unwebsockify on the client:
  32. venv/bin/python unwebsockify.py --port 13232 --subproto mqtt wss://server/
  33. and configure and run the MQTT client instance with e.g.
  34. address