Login Sign Up
WebSocket Engine

Real-Time Code Execution Channel

Execute code with sub-100ms round-trip latency over persistent, bidirectional WebSocket connections. Stream stdout, stderr, and interactive stdin directly between browser consoles and sandboxed cloud containers.

WebSocket Connection Simulator

Watch a real WebSocket handshake, code submission, and execution flow — with accurate timing

client.js
WebSocket Log ● Connected
wss://embedenv.com/ws — persistent connection

Live Latency Monitor

Real-time round-trip ping measurements to execution containers

Current Ping
18ms
Average
22ms
Min / Max
8 / 38ms
Throughput
142 msg/s
Last 10 Pings
Connected

How It Works

Three steps from connection to streaming results

1

Connect WebSocket

Open a persistent WSS connection to Embedenv's execution gateway. Authenticate with your API key during the handshake — no per-request tokens needed.

2

Send Code Payload

Transmit JSON payloads containing your source code, language target, and execution options. Messages are framed and delivered in under 5ms on the wire.

3

Stream Results

Receive stdout, stderr, and exit codes streamed back in real time as they're produced — no waiting for complete execution before seeing output.

Engine Capabilities

Built for real-time, interactive code execution at scale

Sub-100ms Execution

Bidirectional WebSocket connections bypass HTTP request overhead. Code payloads reach execution containers and return results in under 100 milliseconds.

Bidirectional Stdin

Pipe interactive user input directly into running programs. Support for Python's input(), C's scanf(), and Node.js readline over the same persistent channel.

Input Sanitization

Gateway-level filtering blocks dangerous system calls, fork bombs, and file system escape attempts before code reaches the sandboxed execution environment.

Multi-Language Support

Execute code in 34 languages including Python, JavaScript, C, C++, Java, Go, Rust, Ruby, PHP, TypeScript, and Kotlin — all over a single WebSocket connection.

Session Persistence

Long-lived connections maintain execution context across multiple code runs. Variables, imports, and environment state persist for the lifetime of the session.

Auto-Reconnect

Client SDKs automatically detect dropped connections and re-establish the WebSocket link with exponential backoff — zero manual reconnection logic needed.

Quickstart Integration

Connect to the WebSocket engine in your preferred language

// Connect to Embedenv WebSocket Engine
const ws = new WebSocket('wss://embedenv.com/ws');

ws.onopen = () => {
  console.log('Connected to Embedenv');
  ws.send(JSON.stringify({
    action: 'execute',
    language: 'python',
    code: 'print("Hello from WebSocket!")',
    api_key: 'your-api-key'
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('stdout:', data.stdout);
  console.log('time:', data.execution_time);
};
# pip install websockets
import asyncio
import websockets
import json

async def execute_code():
    uri = "wss://embedenv.com/ws"
    async with websockets.connect(uri) as ws:
        payload = {
            "action": "execute",
            "language": "python",
            "code": "print('Hello from WebSocket!')",
            "api_key": "your-api-key"
        }
        await ws.send(json.dumps(payload))
        result = json.loads(await ws.recv())
        print(f"stdout: {result['stdout']}")
        print(f"time: {result['execution_time']}ms")

asyncio.run(execute_code())
# HTTP Fallback (REST API) - for environments without WebSocket support

curl -X POST https://embedenv.com/api/v1/execute \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-key" \
  -d '{
    "language": "python",
    "code": "print(\"Hello from REST!\")",
    "timeout": 10
  }'

# Response:
# {
#   "stdout": "Hello from REST!\n",
#   "stderr": "",
#   "exit_code": 0,
#   "execution_time": "87ms"
# }

Protocol Comparison

Why WebSocket is the optimal choice for real-time code execution

Feature WebSocket HTTP REST SSE
Avg Latency ~18ms ~120ms ~85ms
Bidirectional ✓ Full-duplex ✗ Request/Response ✗ Server → Client only
Connection Overhead Single handshake Per-request TCP/TLS Single connection
Interactive Stdin ✓ Native support ✗ Not possible ✗ Not possible
Streaming Output ✓ Real-time frames ✗ Complete response ✓ Event stream
Header Overhead 2-14 bytes/frame ~800 bytes/request ~200 bytes/event
<0ms
Avg Latency
0
Languages Supported
0%
Connection Uptime
0
Container Executions