| name | websocket-devtools-extension |
| description | Chrome/Edge extension for debugging WebSocket connections with message simulation, traffic blocking, and real-time monitoring |
| triggers | ["debug websocket connections in chrome","monitor websocket traffic in browser","simulate websocket messages","block websocket messages for testing","inspect websocket frames in devtools","capture websocket data in background","test websocket error handling","replay websocket messages"] |
WebSocket DevTools Extension
Skill by ara.so — Devtools Skills collection
WebSocket DevTools is a Chrome/Edge browser extension that provides comprehensive WebSocket debugging capabilities including real-time message monitoring, bidirectional message simulation, traffic blocking, and favorites management - all within the browser's native DevTools interface.
Installation
Chrome Web Store
https://chromewebstore.google.com/detail/websocket-devtools/fmnaobbfmjaaaebelkacpmmmpaaefbod
Microsoft Edge Add-ons
https://microsoftedge.microsoft.com/addons/detail/websocket-devtools/idkoddoekbiekjkpfjeadehmknaoppol
Developer Mode (Local Installation)
git clone https://github.com/law-chain-hot/websocket-devtools.git
cd websocket-devtools
Core Concepts
Background Monitoring
The extension automatically captures all WebSocket connections and messages in the background, even when DevTools is closed. This means:
- No missed connections if you open DevTools after WebSocket establishment
- Persistent message history during page lifetime
- Zero configuration required
Traffic Control
- Message Blocking: Intercept and block messages in either direction (client→server or server→client)
- Simulation: Send custom messages as if they came from client or server
- Pattern Matching: Block messages based on content, type, or URL patterns
Favorites System
Save frequently used messages for quick replay and testing scenarios.
Key Features & Usage
1. Monitoring WebSocket Connections
Once installed, the extension automatically captures all WebSocket activity:
const ws = new WebSocket('wss://example.com/socket');
ws.onopen = () => {
console.log('Connected');
ws.send(JSON.stringify({ type: 'auth', token: 'user-token' }));
};
ws.onmessage = (event) => {
console.log('Received:', event.data);
};
ws.onerror = (error) => {
console.error('WebSocket error:', error);
};
2. Message Simulation
Send custom messages to test client/server behavior:
Simulate Server → Client Message
{
"type": "notification",
"title": "Test Alert",
"message": "This is a simulated server message",
"timestamp": 1704067200000
}
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'notification') {
showNotification(data.title, data.message);
}
};
Simulate Client → Server Message
{
"action": "subscribe",
"channel": "trades",
"symbol": "BTC/USD"
}
3. Message Blocking
Block specific messages to test error handling and edge cases:
Block Pattern Example
const ws = new WebSocket('wss://api.example.com/feed');
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'price_update') {
updatePrice(data.symbol, data.price);
}
};
Bidirectional Blocking
const sendWithRetry = async (data, maxRetries = 3) => {
for (let i = 0; i < maxRetries; i++) {
try {
ws.send(JSON.stringify(data));
await waitForAck(data.id);
return;
} catch (error) {
if (i === maxRetries - 1) throw error;
await sleep(1000 * Math.pow(2, i));
}
}
};
4. JSON Message Inspector
Automatically parses and formats JSON messages:
const message = {
event: 'order_placed',
data: {
orderId: '12345',
symbol: 'BTC/USD',
side: 'buy',
quantity: 0.5,
price: 45000,
timestamp: new Date().toISOString()
}
};
ws.send(JSON.stringify(message));
5. Favorites Management
Save and organize frequently used messages:
{
"type": "auth",
"username": "testuser",
"token": "${TEST_AUTH_TOKEN}"
}
{
"action": "subscribe",
"channels": ["ticker", "trades", "orderbook"],
"symbols": ["BTC/USD", "ETH/USD"]
}
{
"type": "error",
"code": 401,
"message": "Unauthorized"
}
Common Patterns
Testing WebSocket Reconnection Logic
class WebSocketClient {
constructor(url) {
this.url = url;
this.reconnectAttempts = 0;
this.maxReconnectAttempts = 5;
this.connect();
}
connect() {
this.ws = new WebSocket(this.url);
this.ws.onopen = () => {
console.log('Connected');
this.reconnectAttempts = 0;
};
this.ws.onclose = () => {
console.log('Disconnected');
this.reconnect();
};
}
reconnect() {
if (this.reconnectAttempts >= this.maxReconnectAttempts) {
console.();
;
}
.++;
delay = .( * .(, .), );
( .(), delay);
}
}
Testing Message Order and Race Conditions
class MessageQueue {
constructor(ws) {
this.ws = ws;
this.queue = [];
this.processing = false;
}
async send(message) {
this.queue.push(message);
if (!this.processing) {
await this.processQueue();
}
}
async processQueue() {
this.processing = true;
while (this.queue.length > 0) {
const message = this.queue.shift();
this.ws.send(JSON.stringify(message));
await this.waitForAck(message.id);
}
this.processing = false;
}
}
Testing Binary Message Handling
const ws = new WebSocket('wss://example.com/binary');
ws.binaryType = 'arraybuffer';
ws.onmessage = (event) => {
if (event.data instanceof ArrayBuffer) {
const view = new DataView(event.data);
const messageType = view.getUint8(0);
const messageId = view.getUint32(1, true);
console.log('Binary message:', messageType, messageId);
processBinaryMessage(event.data);
}
};
Socket.IO Integration
const socket = io('https://example.com', {
transports: ['websocket'],
auth: {
token: process.env.SOCKET_IO_TOKEN
}
});
socket.on('connect', () => {
console.log('Socket.IO connected');
socket.emit('join_room', { room: 'trading' });
});
socket.on('price_update', (data) => {
console.log('Price:', data);
});
Configuration
The extension works with zero configuration, but you can customize behavior:
Extension Settings (in DevTools panel)
Troubleshooting
DevTools Panel Not Showing
Messages Not Being Captured
const ws = new WebSocket('wss://example.com/socket');
Simulation Not Working
{
type: "message",
data: "test"
}
{
type: "message",
id: "msg-123",
timestamp: 1704067200000,
data: "test",
checksum: "abc123"
}
Block Rules Not Applied
{
"type": "heartbeat"
}
{
"*message*": "*error*"
}
{
"type": "/^(ping|pong)$/"
}
Performance Issues with High Message Volume
const ws = new WebSocket('wss://hft.example.com/feed');
Advanced Usage
Testing WebSocket Security
const ws = new WebSocket('wss://secure.example.com/socket');
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'auth',
token: 'invalid-token'
}));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'auth_failed') {
console.error('Authentication failed:', data.reason);
}
};
Multi-Connection Testing
const connections = [];
for (let i = 0; i < 5; i++) {
const ws = new WebSocket(`wss://example.com/socket?client=${i}`);
ws.onopen = () => {
console.log(`Client ${i} connected`);
};
connections.push(ws);
}
Integration with Automated Testing
const testCases = [
{ name: 'Valid Login', message: { type: 'auth', token: 'valid' } },
{ name: 'Invalid Login', message: { type: 'auth', token: 'invalid' } },
{ name: 'Subscribe', message: { type: 'subscribe', channel: 'prices' } }
];
Best Practices
- Always enable background monitoring before loading pages with WebSockets
- Save complex test messages as favorites for repeatability
- Use message filtering to focus on specific message types during debugging
- Export favorites and block rules to share testing scenarios with team
- Clear old connections periodically to maintain performance
- Test both directions - client→server and server→client simulation
- Document your WebSocket protocol using favorites as examples
- Use blocking to test error handling and recovery logic
- Monitor message frequency to identify performance issues
- Check iframe WebSocket support if working with embedded content
Resources