---
title: "Socket.IO Real-time Connection"
method: GET
path: "/websocket"
tags: ["websocket"]
---

# Socket.IO Real-time Connection

`GET /websocket`

## Request

- Base URL: `http://localhost:3000`
- URL: `http://localhost:3000/websocket`
- Auth: none declared

Socket.IO connection for real-time bidirectional communication. The server uses Socket.IO v4.x for WebSocket transport with automatic fallback.

**Connection URL**: `ws://localhost:3000/socket.io/` (or `wss://` for secure connections)

**Socket.IO Client Connection Example**:
```javascript
import { io } from 'socket.io-client';
const socket = io('http://localhost:3000');
```

**Events**:

### Client to Server Events:
- `join` - Join a room/channel
  ```json
  {
    "roomId": "uuid",
    "agentId": "uuid"
  }
  ```

- `leave` - Leave a room/channel
  ```json
  {
    "roomId": "uuid",
    "agentId": "uuid"
  }
  ```

- `message` - Send a message
  ```json
  {
    "text": "string",
    "roomId": "uuid",
    "userId": "uuid",
    "name": "string"
  }
  ```

- `request-world-state` - Request current state
  ```json
  {
    "roomId": "uuid"
  }
  ```

### Server to Client Events:
- `messageBroadcast` - New message broadcast
  ```json
  {
    "senderId": "uuid",
    "senderName": "string",
    "text": "string",
    "roomId": "uuid",
    "serverId": "uuid",
    "createdAt": "timestamp",
    "source": "string",
    "id": "uuid",
    "thought": "string",
    "actions": ["string"],
    "attachments": []
  }
  ```

- `messageComplete` - Message processing complete
  ```json
  {
    "channelId": "uuid",
    "serverId": "uuid"
  }
  ```

- `world-state` - World state update
  ```json
  {
    "agents": {},
    "users": {},
    "channels": {},
    "messages": {}
  }
  ```

- `logEntry` - Real-time log entry
  ```json
  {
    "level": "number",
    "time": "timestamp",
    "msg": "string",
    "agentId": "uuid",
    "agentName": "string"
  }
  ```

- `error` - Error event
  ```json
  {
    "error": "string",
    "details": {}
  }
  ```

## Other responses

- `101`: Switching Protocols - WebSocket connection established

## Changes

- **2026-11-03** `d606a12682bb`: 1 info
  - added the non-success response with the status `101`

[Operation history](https://skmtc.dev/elizaos/apis/eliza-os-api/changes/websocket/get.md)

---

[API](https://skmtc.dev/elizaos/apis/eliza-os-api.md) - [All operations](https://skmtc.dev/elizaos/apis/eliza-os-api/llms.txt) - [OpenAPI document](https://skmtc.dev/elizaos/apis/eliza-os-api/revisions/d606a12682bb?raw)
