tests.ws

WebSocket Echo Server

A WebSocket echo server sends every message back to the sender. Use one to verify your client code works correctly.

Public Echo Servers

Connect to any of these servers using the Online WebSocket Tester or from your own code.

websocket.org

The most widely used public echo server. Reliable and supports both text and binary messages.

wss://echo.websocket.org

Postman

Postman's echo service. Echoes raw messages back to the sender.

wss://ws.postman-echo.com/raw

tests.ws

In Development

Our own echo server. Currently under development.

wss://echo.tests.ws

What Is a WebSocket Echo Server?

An echo server accepts WebSocket connections and sends every received message back to the client unchanged. When you send "hello", you get "hello" back. When you send a JSON object, you get the same JSON object back.

Echo servers are useful for testing because they remove the server-side logic from the equation. If your client sends a message and gets it back correctly, you know the connection, serialization, and message handling all work.

Quick Start

Browser JavaScript

const ws = new WebSocket('wss://echo.websocket.org');

ws.onopen = () => {
  console.log('Connected');
  ws.send('Hello, echo server!');
};

ws.onmessage = (event) => {
  console.log('Received:', event.data);
  // Output: "Received: Hello, echo server!"
};

ws.onclose = (event) => {
  console.log('Closed:', event.code, event.reason);
};

Node.js (ws)

import WebSocket from 'ws';

const ws = new WebSocket('wss://echo.websocket.org');

ws.on('open', () => {
  ws.send('Hello from Node.js');
});

ws.on('message', (data) => {
  console.log('Echo:', data.toString());
  ws.close();
});

Python (websockets)

import asyncio
import websockets

async def test_echo():
    async with websockets.connect('wss://echo.websocket.org') as ws:
        await ws.send('Hello from Python')
        response = await ws.recv()
        print(f'Echo: {response}')

asyncio.run(test_echo())

Command Line (wscat)

npx wscat -c wss://echo.websocket.org
# Type a message and press Enter
# The server echoes it back

Use Cases

  • Verify client connectivity. Check that your WebSocket client connects, sends, and receives messages correctly.
  • Test message formats. Send JSON, binary, or large payloads and verify they round-trip without corruption.
  • Debug reconnection logic. Close and reopen connections to test your reconnection strategy.
  • Measure latency. Send a message and measure the time until the echo arrives to estimate round-trip time.
  • Test close codes. Close the connection with specific codes and verify your client handles them correctly.

Build Your Own Echo Server

If you need a local echo server for testing, you can build one in a few lines of code. Here is a minimal Node.js echo server:

import { WebSocketServer } from 'ws';

const wss = new WebSocketServer({ port: 8080 });

wss.on('connection', (ws) => {
  ws.on('message', (data) => {
    ws.send(data); // Echo the message back
  });
});

console.log('Echo server running on ws://localhost:8080');

For production-grade servers, see the Node.js WebSocket guide or the Python websockets guide.

Related Resources