This package provides a low-level, unopinionated SOCKS v5 client socket implementation specifically designed for Node.js. It allows developers to proxy raw TCP connections through a SOCKSv5 server by wrapping a standard `net.Socket` and performing the SOCKSv5 handshake. First published in 2012 and last updated seven years ago (version 1.2.8), its release cadence is effectively abandoned, although the package remains available and functional for its specific niche. It serves as a foundational component for other packages like `socks5-http-client` and `socks5-https-client`. Unlike more modern SOCKS client libraries, `socks5-client` focuses solely on the SOCKSv5 protocol, operates synchronously, and does not include modern JavaScript features like Promises or built-in TypeScript definitions. Its key differentiator is its minimalist approach, providing direct control over the underlying socket stream for advanced use cases.
npm install socks5-clientVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to establish a SOCKSv5 proxied TCP connection to `example.com` on port 80. It first connects a raw `net.Socket` to the SOCKS5 proxy, then uses `socks5-client` to perform the SOCKS5 handshake and obtain a `destinationSocket` which is then used to send an HTTP GET request to the target host.
For ESM projects, use `const SocksClient = require('socks5-client');` or consider a dynamic import: `const SocksClient = (await import('socks5-client')).default;`. For TypeScript, ensure `esModuleInterop` is enabled and use `import SocksClient = require('socks5-client');` or `import * as SocksClient from 'socks5-client';`.Evaluate alternatives like the `socks` package (npm: `socks`), which is actively maintained, supports Promises, TypeScript, and multiple SOCKS versions. If forced to use `socks5-client`, thorough testing across target Node.js versions is crucial, and be prepared to patch the code or implement workarounds for modern environments.
If your use case requires SOCKS4, UDP, or complex authentication, `socks5-client` is not suitable. Consider libraries like `socks` (npm: `socks`) that offer broader protocol and feature support. Validate that your SOCKSv5 proxy supports the authentication methods provided by `socks5-client`.
Change your import statement to `const SocksClient = require('socks5-client');`. If using TypeScript, ensure `esModuleInterop` is true in `tsconfig.json` and use `import SocksClient = require('socks5-client');` or `import * as SocksClient from 'socks5-client';`.Verify that your SOCKS5 proxy server is operational and reachable from the machine running your Node.js application. Double-check the `PROXY_HOST` and `PROXY_PORT` configurations. Firewall rules might also be blocking the connection.
Ensure the SOCKS proxy is indeed a SOCKSv5 server. If using authentication, double-check `socksUsername` and `socksPassword` are correct and supported by the proxy. Verify that the `TARGET_HOST` and `TARGET_PORT` are valid and allowed by the proxy's rules. Check proxy logs for more specific error details.
This suggests a core incompatibility. Consider downgrading Node.js if possible, or migrate to a more actively maintained SOCKS client library that is compatible with your current Node.js version. There's no direct fix within `socks5-client` itself without patches.
No dependency data recorded yet.