{"id":14961,"library":"tcp-ping","title":"TCP Ping Utility","description":"This Node.js utility provides TCP-based ping functionality, enabling users to test the availability and measure the latency of specific services on given addresses and ports. Unlike traditional ICMP `ping` tools, `tcp-ping` avoids issues with ICMP-blocked servers and offers faster results by immediately dropping connections after acceptance. It's particularly useful for verifying service-level availability rather than just general network connectivity. The package's current and only documented version is 0.1.1, indicating a very early stage of development or a project that is no longer actively maintained. Its release cadence is effectively non-existent. Key differentiators include its speed, the ability to target specific ports and services, and its resilience to ICMP filtering, making it more effective for certain server monitoring scenarios.","status":"abandoned","version":"0.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/wesolyromek/tcp-ping","tags":["javascript","ping","util","tcp","availability"],"install":[{"cmd":"npm install tcp-ping","lang":"bash","label":"npm"},{"cmd":"yarn add tcp-ping","lang":"bash","label":"yarn"},{"cmd":"pnpm add tcp-ping","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This is the canonical CommonJS import method for this package, typical for older Node.js projects.","symbol":"tcpp","correct":"const tcpp = require('tcp-ping');"},{"note":"While Node.js's interoperability allows default ES module imports for CommonJS modules, named imports for 'ping' or 'probe' will fail as the package exports a single object, not individual functions.","wrong":"import { ping, probe } from 'tcp-ping';","symbol":"tcpp","correct":"import tcpp from 'tcp-ping';"},{"note":"This ES module 'namespace' import bundles all CommonJS exports into a single 'tcpp' object, ensuring compatibility in modern module contexts.","symbol":"tcpp (namespace import)","correct":"import * as tcpp from 'tcp-ping';"}],"quickstart":{"code":"const tcpp = require('tcp-ping');\n\nconst targetAddress = '46.28.246.123'; // Replace with a real IP or hostname\nconst targetPort = 80;\n\ntcpp.probe(targetAddress, targetPort, function(err, available) {\n    if (err) {\n        console.error(`Probe error for ${targetAddress}:${targetPort}:`, err.message);\n    } else {\n        console.log(`Service at ${targetAddress}:${targetPort} available: ${available}`);\n    }\n});\n\ntcpp.ping({ address: targetAddress, port: targetPort, attempts: 5, timeout: 2000 }, function(err, data) {\n    if (err) {\n        console.error(`Ping error for ${targetAddress}:${targetPort}:`, err.message);\n    } else {\n        console.log(`Ping results for ${targetAddress}:${targetPort}:`);\n        console.log(`  Attempts: ${data.attempts}`);\n        console.log(`  Average latency: ${data.avg.toFixed(2)}ms`);\n        console.log(`  Min latency: ${data.min.toFixed(2)}ms`);\n        console.log(`  Max latency: ${data.max.toFixed(2)}ms`);\n        // console.log('  Raw results:', data.results);\n    }\n});","lang":"javascript","description":"This example demonstrates how to use `tcp-ping` to both probe for service availability and measure latency statistics for a given address and port."},"warnings":[{"fix":"Consider using a more actively maintained TCP ping utility or implement custom socket-based checks for critical applications. Evaluate thoroughly if compatibility issues arise with modern Node.js environments.","message":"The package is at version 0.1.1 and has not seen updates since its initial release. This implies potential compatibility issues with newer Node.js versions or dependencies, and a lack of security patches for any discovered vulnerabilities.","severity":"breaking","affected_versions":"0.1.1"},{"fix":"Wrap `tcp-ping` calls in Promises using `util.promisify` (if applicable for `(err, data)` callback structure) or manual Promise constructors to integrate with `async/await` patterns.","message":"The API is entirely callback-based, which is common for older Node.js libraries. It does not provide Promise-based interfaces or support `async/await` directly, leading to potential 'callback hell' in complex asynchronous flows.","severity":"gotcha","affected_versions":"0.1.1"},{"fix":"Always implement robust error handling in the callback function. Ensure the target address is reachable and the port is open to receive connections for accurate results.","message":"The package uses Node.js's `net` module internally. Incorrect usage of `address` or `port` options, or attempting to ping non-routable/firewalled addresses, will result in network errors (e.g., `ECONNREFUSED`, `ETIMEDOUT`, `EHOSTUNREACH`) rather than simple `true`/`false` responses.","severity":"gotcha","affected_versions":"0.1.1"}],"env_vars":null,"search_vec":"'0.1.1':81 'abil':112 'accept':55 'activ':96 'address':28 'avail':18,65,138 'avoid':39 'base':10 'block':44 'cadenc':100 'certain':130 'connect':53,71 'current':75 'develop':88 'differenti':107 'document':78 'drop':52 'earli':85 'effect':102,128 'enabl':13 'exist':105 'faster':48 'filter':124 'function':12 'general':69 'given':27 'icmp':33,43,123 'icmp-block':42 'immedi':51 'includ':108 'indic':82 'issu':40 'javascript':134 'key':106 'latenc':22 'level':64 'longer':95 'maintain':97 'make':125 'measur':20 'monitor':132 'network':70 'node.js':5 'non':104 'non-exist':103 'offer':47 'packag':73 'particular':58 'ping':2,11,34,38,135 'port':30,116 'project':91 'provid':7 'rather':66 'releas':99 'resili':121 'result':49 'scenario':133 'server':45,131 'servic':25,63,118 'service-level':62 'specif':24,115 'speed':110 'stage':86 'target':114 'tcp':1,9,37,137 'tcp-base':8 'tcp-ping':36 'test':16 'tool':35 'tradit':32 'unlik':31 'use':59 'user':14 'util':3,6,136 'verifi':61 'version':79","created_at":"2026-04-20T18:44:32.336549+00:00","updated_at":"2026-04-20T18:44:32.336549+00:00","problems":[{"fix":"For ES module environments, use `import tcpp from 'tcp-ping';` or `import * as tcpp from 'tcp-ping';`. Alternatively, ensure your file is treated as CommonJS (e.g., `.js` file without `type: \"module\"`).","cause":"Attempting to use `require()` in an ES module context (`type: \"module\"` in package.json or `.mjs` file).","error":"ReferenceError: require is not defined"},{"fix":"Verify that the target service is running, the port is correct, and network configurations (including firewalls) allow connections from the origin machine.","cause":"The target server actively refused the connection, likely because no service is listening on the specified port, a firewall is blocking the connection, or the server is not running.","error":"Error: connect ECONNREFUSED"},{"fix":"Increase the `timeout` option in the `ping` function (e.g., `timeout: 10000` for 10 seconds) or check network connectivity and firewalls between the client and server.","cause":"The connection attempt timed out, meaning the server did not respond within the specified `timeout` period (or default 5s). This can be due to network congestion, a firewall silently dropping packets, or the host being down/unreachable.","error":"Error: connect ETIMEDOUT"},{"fix":"Ensure `const tcpp = require('tcp-ping');` or `import tcpp from 'tcp-ping';` is at the top of your file and the `tcpp` variable is used consistently.","cause":"The `tcpp` object was not correctly imported, or the variable name `tcpp` is misspelled, preventing access to its `ping` method.","error":"TypeError: tcpp.ping is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/wesolyromek/tcp-ping","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/tcp-ping","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","observability","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}