{"id":22339777,"url":"https://github.com/scriptollc/hammer-time","last_synced_at":"2025-07-30T00:31:22.796Z","repository":{"id":22824447,"uuid":"26171422","full_name":"scriptoLLC/hammer-time","owner":"scriptoLLC","description":"🔨 Stop! Hammertime!","archived":false,"fork":false,"pushed_at":"2018-10-08T17:29:39.000Z","size":24,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-06-29T14:42:03.410Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scriptoLLC.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-04T14:08:32.000Z","updated_at":"2018-10-11T21:23:50.000Z","dependencies_parsed_at":"2022-08-17T16:55:34.659Z","dependency_job_id":null,"html_url":"https://github.com/scriptoLLC/hammer-time","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/scriptoLLC/hammer-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fhammer-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fhammer-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fhammer-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fhammer-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scriptoLLC","download_url":"https://codeload.github.com/scriptoLLC/hammer-time/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fhammer-time/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267785731,"owners_count":24144119,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T07:09:22.540Z","updated_at":"2025-07-30T00:31:22.517Z","avatar_url":"https://github.com/scriptoLLC.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build status](https://secure.travis-ci.org/scriptollc/hammer-time.png)](http://travis-ci.org/scriptollc/hammer-time)\n\n# hammer-time\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/scriptoLLC/hammer-time.svg)](https://greenkeeper.io/)\n\nCreate a swarm of socket.io clients to stress test your socket-based application.  Provides hooks to allow for HTTP based authentication to be passed into the socket connection requests if necessary, as well as listening to and responding to various socket events.\n\n## Install/Run\n\n```\nnpm i -g hammer-time\nhammer-time example.com --port 9000 --concurrent 50 --frequency 6000 --duration 100000 --generator my-gen.js\n```\n\n## Usage\n\n```\nUsage: hammer-time [host] -p [port] -c [concurrency] -f [frequency] -d [duration] -g [generator]\n\nOptions:\n  --version     Print the version number\n  -p, --port        What port to use. Default = 80\n  -c, --concurrent  How many clients to run concurrently. Default = 100\n  -f, --frequency   Frequency of client messages (ms). Default = 50\n  -d, --duration    Length of test (ms). Default = 60000 (1 minute)\n  -g, --generator   Name of generator file to load, if any. This will specify\n                    the details of how to connect and authenticate to your socket server\n  -v, --verbose     Be extremely loud about what it is doing\n\n\n```\n\n## Programmatic Access\n\nhammer-time is also available as module that can be used outside of the scope of the CLI. (This is how the tests are run!). The arguments to the method are\nthe same (and in the same order!) as the CLI, with the addition of an optional callback to be called when the tests are complete.  The method returns an event emitter\nwhich you can use for monitoring the process.  The [CLI interface](bin/hammer-time.js) is a great example of how this works.\n\n```\nvar ht = require('hammer-time');\nht(host, port, concurrent, frequency, duration, generator)\n\t.on('start', function(){\n\t\tconsole.log('hammer time is starting');\n\t})\n\t.on('error', function(err){\n\t\tconsole.log(err);\n\t});\n```\n\n### Events\n* `start` → The client has started, but not asked any clients to yet connect\n* `client-connected` → A client has connected to the server and the handshake is complete. If you have an event named `connect`, in your `exports.events` object, that method will be called immediately after this message is emitted.\n* `message` → A client has sent a message to the server, the message is passed as an argument\n* `disconnect` → A client has disconnected from the server\n* `end` → hammer-time has run for the set duration\n* `error` → hammer-time encountered as an error. The error is passed as an argument\n\n\n## Generator\n\nGenerators allow you to set custom authentication methods, listeners for the socket, and what message(s) the client should send to flood the server.\n\nThe generator *should* export the following symbols (none of these are required, but it might not do much if you don't provide one).\n\nSee [examples/default-generator.js](examples/default-generator.js) for an example of how this works.\n\n* `exports.events` → _object_ of functions where the key is the event name, and the value is the function to run for that event\n\n\n```\n{\n  [eventname]: function(event name, cookies, username, password, message data, socket object, emitter returned from API)\n}\n```\n\nThe function's signature is:\n\n```\n/**\n * Respond to an event\n * @method event\n * @param  {string} the name of the event you're responding to\n * @param  {object} any cookies returned from your auth method\n * @param  {string} the username that was used for authenticating this socket\n * @param  {string} the password that was used for authenticating this socket\n * @param  {object} the message from the socket.io server\n * @param  {object} the socket client\n * @param  {object} the emitter returned from the function. Allows you to emit data to the CLI or other listeners\n */\n```\n\n* `exports.authenticate` → `function(host, port, iteration, cb)`\n\n```\n/**\n * Authenticate for a client\n * @method  authenticate\n * @async\n * @param   {string} host hostname\n * @param   {integer} port portname\n * @param   {integer} iteration what client number to generate\n * @param   {Function} cb `err` on error, `err`, `cookies`, `username`, `password` on success\n * @returns {object} undefined\n */\n```\n**note**: `cookies` should be an object of parsed cookies, and username, password will be the credentials used to authenicate.  If authenication fails, the callback should receive an error\n\n* `exports.getSocketUrl` → `function(host, port, cookies)`\n\n```\n/**\n * Returns the URL to send to the `io.connect` method.\n * @method  getSocketURL\n * @param   {string} host host name\n * @param   {integer} port port\n * @param   {object} cookies if you need them\n * @returns {string} The URL that should be passed to the socket.io constructor\n */\n```\n\n* `exports.clientIterateMessage` → `function(cookies, user, pass)`\n\n```\n/**\n * Returns a message to send to the client\n * @method  clientIterateMessage\n * @param   {object} cookies Any cookies you might need\n * @param   {string} user the name of the user who authenciated\n * @param   {string} pass the password of the user who authenciated\n * @returns {object} The message you'd like to pass to the server, or `false` if there is no message\n */\n```\n\n\n\n## License\nCopyright ©2014 Scripto, LLC. Available under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptollc%2Fhammer-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscriptollc%2Fhammer-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptollc%2Fhammer-time/lists"}