Back to Challenges
🔌 WebSocket Hub
Bidirectional real-time communication. Connect to public echo servers or your own WebSocket endpoint.
Connection
disconnected
Server
Settings
Quick Send
Messages (0)
Sent Received
No messages yet
Connect and send a message to start
Testing Guide
JavaScript Client
const ws = new WebSocket('wss://echo.websocket.org');
ws.onopen = () => {
console.log('Connected');
ws.send('Hello Server!');
};
ws.onmessage = (event) => {
console.log('Received:', event.data);
};
ws.onclose = (event) => {
console.log('Closed:', event.code);
};
ws.onerror = (error) => {
console.error('Error:', error);
};Playwright Test
import { test, expect } from '@playwright/test';
test('websocket connection', async ({ page }) => {
// Navigate to page that uses WebSocket
await page.goto('/websocket');
// Listen for WebSocket events
page.on('websocket', ws => {
ws.on('framesent', e =>
console.log('Sent:', e.payload));
ws.on('framereceived', e =>
console.log('Received:', e.payload));
});
// Interact with WebSocket UI
await page.click('button:has-text("Connect")');
await page.fill('input', 'test message');
await page.click('button:has-text("Send")');
// Verify response
await expect(page.locator('.message'))
.toContainText('test message');
});Common Test Scenarios
- ✓ Connection establishment
- ✓ Message sending and receiving
- ✓ JSON message parsing
- ✓ Connection error handling
- ✓ Auto-reconnect behavior
- ✓ Ping/pong heartbeat
- ✓ Graceful disconnection
- ✓ Multiple concurrent connections
Public Test Servers
wss://echo.websocket.org- Echo serverwss://ws.postman-echo.com/raw- Postman echowss://socketsbay.com/wss/v2/1/demo/- SocketsBay demo