pitfalls-websocket
Implement WebSocket servers with best practices
WebSocket implementations often fail silently due to missing heartbeat or reconnection logic. This skill provides verified patterns for robust real-time connections that survive network issues and handle message validation correctly.
Baixar o ZIP da skill
Upload no Claude
Vá em Configurações → Capacidades → Skills → Upload skill
Ative e comece a usar
Testar
A utilizar "pitfalls-websocket". Review my WebSocket server code
Resultado esperado:
- ✓ Server shares HTTP port correctly
- ✗ Missing heartbeat - add ping interval every 30 seconds
- ✗ No reconnection logic for clients
- ✓ Message parsing includes try-catch for invalid JSON
- Recommendation: Add ws.isAlive flag and pong handler to detect dead connections
A utilizar "pitfalls-websocket". Add heartbeat to my WebSocket server
Resultado esperado:
- Added ping-pong heartbeat with 30-second interval
- Implemented isAlive flag to track connection health
- Added terminate() for dead connections
- Included pong handler to reset isAlive on response
Auditoria de Segurança
SeguroPure documentation skill containing only TypeScript code examples for educational purposes. No executable code, file system access, network calls, or command execution capabilities. All static findings are false positives caused by the scanner misinterpreting code examples in markdown documentation as executable patterns. The previous audit (skill-report.json) correctly identified this as safe.
Fatores de risco
🌐 Acesso à rede (2)
📁 Acesso ao sistema de arquivos (1)
⚙️ Comandos externos (5)
Pontuação de qualidade
O Que Você Pode Construir
Build production WebSocket server
Create WebSocket server with heartbeat, proper message handling, and connection lifecycle management
Implement resilient client
Build WebSocket client that reconnects automatically after network interruptions
Audit real-time code
Review WebSocket implementation for missing heartbeat, error handling, or reconnection logic
Tente Estes Prompts
Review my WebSocket server code. Check if it shares the HTTP port, has heartbeat implemented, and handles client connections correctly.
Add heartbeat ping-pong mechanism to my WebSocket server. Show how to detect dead connections and terminate them gracefully.
Implement WebSocket client reconnection with exponential backoff. Include connection state tracking and error logging.
Review my WebSocket message handling. Add proper JSON parsing, type validation, and error responses for invalid messages.
Melhores Práticas
- Use same port for WebSocket server and HTTP server to simplify deployment
- Implement heartbeat every 30 seconds to detect stale connections early
- Reset reconnection attempt counter on successful connection
- Validate and type all incoming messages before processing
Evitar
- Skipping heartbeat - leads to ghost connections consuming resources
- No reconnection logic - clients stay disconnected after network issues
- Processing raw messages without validation - security risk
Perguntas Frequentes
What tools support this skill?
What are the connection timeout limits?
Can I integrate with existing WebSocket libraries?
Is my WebSocket data stored or logged?
Why do connections drop unexpectedly?
How does this compare to Socket.io?
Detalhes do Desenvolvedor
Estrutura de arquivos
📄 SKILL.md