Skip to main content

Outray

outray is a Python library for creating HTTP, TCP, and UDP tunnels using https://outray.dev/. It allows you to forward local services to a remote endpoint easily.

Install via pip:

pip install outray

Features

  • HTTP tunnel proxy (HttpListener)
  • TCP tunnel proxy (TCPListener)
  • UDP tunnel proxy (UDPListener)
  • Forward a tunnel asynchronously or synchronously
  • Built-in error handling and logging

Usage Example

  • Asynchronous
import asyncio
from outray import forward, http

async def main():
    listener = http("http://localhost:8080")
    await forward(listener)

asyncio.run(main())
  • Synchronous
import asyncio
from outray import forward, http

listener = http("http://localhost:8080")
forward_sync(listener)

API

## Environment Variables

Outray supports configuration via environment variables. These are optional but recommended.

### `OUTRAY_API_KEY`

Your API key used to authenticate tunnel connections.

```bash
export OUTRAY_API_KEY=your_api_key_here

If not provided explicitly, forward and forward_sync will automatically read this value from the environment.

Equivalent code usage:

await forward(l1)
await forward(l1, api_key="API_KEY")

OUTRAY_API_URI

The WebSocket endpoint used to establish tunnels.

export OUTRAY_API_URI=wss://api.outray.app

If not provided explicitly, this value is also read from the environment.

Equivalent code usage:

await forward(l1, api_key="API_KEY", ws_url="API_URL")

Creating a Listener

TCP

from outray import tcp

listener = tcp(local_host="localhost", local_port=8090, remote_port=20710)

UDP

from outray import udp

listener = udp(local_host="localhost", local_port=9000, remote_port=30710)

HTTP

from outray import http

listener = http(url="http://localhost:8080", subdomain="my-subdomain")

Forwarding a Tunnel

Asynchronous (forward)

from outray import forward
import asyncio

asyncio.run(forward(listener))
  • forward(listener, ws_url=None, force_takeover=None, ping_interval=20, ping_timeout=20, api_key=None)
  • Forwards the listener to the remote WebSocket tunnel.
  • Handles reconnects automatically.

Synchronous (forward_sync)

from outray import forward_sync

forward_sync(listener)
  • Same as forward but runs in a blocking synchronous context.
  • Useful for scripts that do not use asyncio natively.

Logging

outray uses the standard Python logging module. To see detailed tunnel events:

import logging

logger = logging.getLogger("outray")
logger.setLevel(logging.DEBUG)

Metadata

Release files for outray 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for outray 0.0.3
File Size Uploaded
outray-0.0.3.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for outray 0.0.3
File Interpreter ABI Platform
outray-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 19.6 kB

Release files / outray-0.0.3.tar.gz

Download URL outray-0.0.3.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
23d4173ae09d0c20dbe46c2e3e676eedf76fb25a8673b299a34487f76355fc91
BLAKE2b-256 checksum
How to use checksums
eb738de713dad20c90023ca966f3941e1797567aa3c79261cb29985db9325411
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / outray-0.0.3-py3-none-any.whl

Download URL outray-0.0.3-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d93660a5801bc31369c0c8ea3bb5cb56f41a4ec573cdc064c1203078cfa5a87
BLAKE2b-256 checksum
How to use checksums
3bc19795375c5d085695b7a3e5dd690b3b8f53e558378608b7eb01cbc210e5f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page