Skip to content

Quick Start

Get RevenProx running in under 5 minutes.

Step 1: Create Configuration

Create a configuration file proxy.toml:

# System settings
proxy_id = "proxy-1"
log_level = "info"
metrics_enabled = true

[http]
bind_address = "0.0.0.0:8080"
max_connections = 10000
connection_timeout_sec = 300
keepalive_interval_sec = 30

[jwt_verifier]
webhook_url = "http://your-auth-server/verify"
timeout_ms = 5000
retry_attempts = 3
cache_ttl_sec = 300
require_authentication = true

[limits]
max_memory_mb = 1024
max_cpu_percent = 80
max_file_descriptors = 65536

Step 2: Start the Proxy

./sse-proxy --config proxy.toml

You should see:

[INFO] Starting HTTP server on 0.0.0.0:8080
[INFO] HTTP server started successfully
[INFO] Thread pool initialized with 8 workers

Step 3: Connect a Client

Using curl

curl -N "http://localhost:8080/events/my-topic" \
  -H "Authorization: Bearer <your-jwt-token>"

Using JavaScript

const eventSource = new EventSource(
  'http://localhost:8080/events/my-topic',
  {
    headers: {
      'Authorization': 'Bearer <your-jwt-token>'
    }
  }
);

eventSource.onmessage = (event) => {
  console.log('Received:', event.data);
};

eventSource.onerror = (error) => {
  console.error('SSE Error:', error);
};

Using Python

import sseclient
import requests

url = 'http://localhost:8080/events/my-topic'
headers = {'Authorization': 'Bearer <your-jwt-token>'}

response = requests.get(url, headers=headers, stream=True)
client = sseclient.SSEClient(response)

for event in client.events():
    print(f"Received: {event.data}")

Step 4: Set Up JWT Verification

RevenProx verifies JWT tokens by calling your webhook. Your webhook should:

  1. Accept POST requests with JSON body:

    {
      "jwt": "eyJhbGciOiJIUzI1NiIs...",
      "topic": "a1b2c3d4e5f6..."
    }
    

  2. Return a JSON response:

    {
      "valid": true,
      "user_id": "user123",
      "expires_at": 1735689600
    }
    

Example Webhook (Node.js)

const express = require('express');
const jwt = require('jsonwebtoken');

const app = express();
app.use(express.json());

app.post('/verify', (req, res) => {
  const { jwt: token, topic } = req.body;

  try {
    const decoded = jwt.verify(token, process.env.JWT_SECRET);

    res.json({
      valid: true,
      user_id: decoded.sub,
      expires_at: decoded.exp
    });
  } catch (error) {
    res.json({
      valid: false,
      user_id: null,
      expires_at: null
    });
  }
});

app.listen(9000, () => {
  console.log('JWT verification webhook running on port 9000');
});

Step 5: Disable Authentication (Development Only)

For development, you can disable JWT authentication:

[jwt_verifier]
webhook_url = ""
require_authentication = false

Warning

Never disable authentication in production!

Testing the Setup

Health Check

curl http://localhost:8080/health

Subscribe to Events

# Terminal 1: Subscribe
curl -N "http://localhost:8080/events/test-topic"

# Terminal 2: The proxy will stream any events published to test-topic

Common Issues

Connection Refused

curl: (7) Failed to connect to localhost port 8080

Solution: Ensure the proxy is running and listening on the correct address.

Authentication Failed

HTTP/1.1 401 Unauthorized

Solution: Check that: - Your JWT token is valid - The webhook URL is accessible - The webhook returns the correct response format

Too Many Connections

HTTP/1.1 503 Service Unavailable

Solution: Increase max_connections in configuration or check for connection leaks.

Next Steps