{"id":18760,"library":"rocky","title":"Rocky","description":"A full-featured, middleware-oriented HTTP/S and WebSocket proxy with traffic replay, load balancing, routing, and retry/backoff. Current stable version is 0.4.16, last updated July 2020. It is built on top of http-proxy and supports both command-line and programmatic usage. Key differentiators include a hierarchical middleware layer, path-based routing with params, concurrent/sequential traffic replay, and connectivity with Connect/Express middleware. Compared to alternatives like http-proxy or http-mitm-proxy, Rocky provides a higher-level abstraction with built-in balancer and retry logic. The project is in maintenance mode; no major releases since 2020.","status":"maintenance","version":"0.4.16","language":"javascript","source_language":"en","source_url":"https://github.com/h2non/rocky","tags":["javascript","http","websocket","proxy","http-proxy","reverse","migration","migrate","repeat"],"install":[{"cmd":"npm install rocky","lang":"bash","label":"npm"},{"cmd":"yarn add rocky","lang":"bash","label":"yarn"},{"cmd":"pnpm add rocky","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core proxy functionality for HTTP and WebSocket proxying","package":"http-proxy","optional":false}],"imports":[{"note":"CommonJS only; no ESM support. The default export is the factory function.","wrong":"import rocky from 'rocky'","symbol":"rocky","correct":"const rocky = require('rocky')"},{"note":"Balancer is exposed as a property on the rocky object.","symbol":"rocky.balancer","correct":"const balancer = require('rocky').balancer"},{"note":"Middleware signature is (req, res, next) similar to Express; must call next() to continue.","wrong":"proxy.use(middleware) without calling next()","symbol":"RockyMiddleware","correct":"const Rocky = require('rocky'); const proxy = Rocky(); proxy.use((req, res, next) => next())"}],"quickstart":{"code":"const rocky = require('rocky');\nconst proxy = rocky();\n\n// Forward all traffic to httpbin\nproxy\n  .target('http://httpbin.org')\n  .forward(async (req, res, next) => {\n    console.log('Forward request:', req.url);\n    await next();\n  })\n  .replay(async (req, res, next) => {\n    console.log('Replay response:', res.statusCode);\n    await next();\n  });\n\nproxy.listen(3000, () => {\n  console.log('Rocky proxy listening on port 3000');\n});\n\n// Test: curl -x http://localhost:3000 http://httpbin.org/get","lang":"javascript","description":"Sets up a simple HTTP proxy that forwards all traffic to httpbin.org, with middleware hooks for forward and replay phases."},"warnings":[{"fix":"Disable retry or avoid using retry options; consider implementing retry manually.","message":"retry feature is temporarily not available in latest Node.js versions (see README note).","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Use const proxy = require('rocky')() to create an instance.","message":"The default export is a function that creates a new proxy instance; not a class constructor.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure every middleware function ends with await next() or next() (if not async).","message":"Middleware must call next() or the request hangs. Rocky does not automatically call next().","severity":"gotcha","affected_versions":"all"},{"fix":"Use rocky() instead of new rocky()","message":"In version 0.3.x, the proxy was created via new Rocky(), but in 0.4.x it changed to factory function.","severity":"breaking","affected_versions":">=0.4.0"},{"fix":"Use forward only for WebSocket; replay not available.","message":"WebSocket proxy does not support replay to multiple backends.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change to const rocky = require('rocky')","cause":"Using import instead of require with CommonJS module.","error":"TypeError: rocky is not a function"},{"fix":"Kill the process using the port or choose a different port.","cause":"Port already in use by another process.","error":"Error: EADDRINUSE :::3000"},{"fix":"Create an instance: const proxy = require('rocky')()","cause":"Forgot to call rocky() to create an instance; using module directly.","error":"rocky().target is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}