skillZs
★ LIVE SKILL TAGS ★
>>> LIVE SKILLS INDEX <<<
* OPEN SOURCE *
NO LOGIN, NO TRACKING
※ REAL INSTALL DATA ※
← back to all skills
aj-geddes/useful-ai-prompts651 installs

websocket-implementation

Implement real-time bidirectional communication with WebSockets including connection management, message routing, and scaling. Use when building real-time features, chat systems, live notifications, or collaborative applications.

How do I install this agent skill?

npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill websocket-implementation
view source ↗

Is this agent skill safe to install?

  • Gen Agent Trust Hubpass

    The skill provides templates for WebSocket implementations in Node.js and Python. It includes a permissive CORS configuration (origin set to '*') in the Node.js examples, which could allow unauthorized connections in web environments. Additionally, it lacks input sanitization for user-submitted chat messages that are persisted to a database, creating a surface for potential injection attacks.

  • Socketwarn

    2 alerts: gptSecurity

  • Snykpass

    Risk: LOW · No issues

  • Runlayerwarn

    2/10 files flagged

  • ZeroLeakspass

    Score: 93/100 · 2 sections analyzed

What does this agent skill do?

WebSocket Implementation

Table of Contents

Overview

Build scalable WebSocket systems for real-time communication with proper connection management, message routing, error handling, and horizontal scaling support.

When to Use

  • Building real-time chat and messaging
  • Implementing live notifications
  • Creating collaborative editing tools
  • Broadcasting live data updates
  • Building real-time dashboards
  • Streaming events to clients
  • Live multiplayer games

Quick Start

Minimal working example:

const express = require("express");
const http = require("http");
const socketIo = require("socket.io");
const redis = require("redis");

const app = express();
const server = http.createServer(app);
const io = socketIo(server, {
  cors: { origin: "*" },
  transports: ["websocket", "polling"],
  reconnection: true,
  reconnectionDelay: 1000,
  reconnectionDelayMax: 5000,
  reconnectionAttempts: 5,
});

// Redis adapter for horizontal scaling
const redisClient = redis.createClient();
const { createAdapter } = require("@socket.io/redis-adapter");

io.adapter(createAdapter(redisClient, redisClient.duplicate()));

// Connection management
const connectedUsers = new Map();

// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
Node.js WebSocket Server (Socket.IO)Node.js WebSocket Server (Socket.IO)
Browser WebSocket ClientBrowser WebSocket Client
Python WebSocket Server (aiohttp)Python WebSocket Server (aiohttp)
Message Types and ProtocolsMessage Types and Protocols
Scaling with RedisScaling with Redis

Best Practices

✅ DO

  • Implement proper authentication
  • Handle reconnection gracefully
  • Manage rooms/channels effectively
  • Persist messages appropriately
  • Monitor active connections
  • Implement presence features
  • Use Redis for scaling
  • Add message acknowledgment
  • Implement rate limiting
  • Handle errors properly

❌ DON'T

  • Send unencrypted sensitive data
  • Keep unlimited message history in memory
  • Allow arbitrary room/channel creation
  • Forget to clean up disconnected connections
  • Send large messages frequently
  • Ignore network failures
  • Store passwords in messages
  • Skip authentication/authorization
  • Create unbounded growth of connections
  • Ignore scalability from day one

Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.

<a href="https://skillzs.dev/skills/aj-geddes/useful-ai-prompts/websocket-implementation">View websocket-implementation on skillZs</a>