{"id":34816344,"url":"https://github.com/vphantom/longwebsocket","last_synced_at":"2026-05-25T19:35:32.085Z","repository":{"id":58238665,"uuid":"56640792","full_name":"vphantom/longwebsocket","owner":"vphantom","description":"Reconnecting wrapper around native WebSocket","archived":false,"fork":false,"pushed_at":"2016-04-21T17:17:42.000Z","size":25,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-26T03:39:02.409Z","etag":null,"topics":["javascript","npm-module","websockets"],"latest_commit_sha":null,"homepage":null,"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/vphantom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-19T23:58:31.000Z","updated_at":"2016-04-20T01:08:27.000Z","dependencies_parsed_at":"2022-08-31T00:30:50.703Z","dependency_job_id":null,"html_url":"https://github.com/vphantom/longwebsocket","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/vphantom/longwebsocket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vphantom%2Flongwebsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vphantom%2Flongwebsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vphantom%2Flongwebsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vphantom%2Flongwebsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vphantom","download_url":"https://codeload.github.com/vphantom/longwebsocket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vphantom%2Flongwebsocket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33490980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T14:31:05.219Z","status":"ssl_error","status_checked_at":"2026-05-25T14:31:02.878Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["javascript","npm-module","websockets"],"created_at":"2025-12-25T13:40:31.767Z","updated_at":"2026-05-25T19:35:32.079Z","avatar_url":"https://github.com/vphantom.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# longwebsocket v1.0.1-beta\n\nReconnecting wrapper around native WebSocket\n\nWhile browsers' native WebSocket object simply stops functioning when the connection is lost, this module takes care of reviving the connection and keeping handlers active.  It also makes sure to randomize progressively longer delays up to 30 seconds between retries to avoid flooding a server as it comes back online.\n\n## Installation \u0026 Usage\n\n### Client-side, stand-alone using Bower\n\n```sh\nbower install longwebsocket --save\n```\n\nYou can then integrate `bowe_components/longwebsocket/longwebsocket.min.js` to your build as needed.  (The non-minified version is a CommonJS module, not suitable for direct browser use.)  This was generated using `browserify --standalone` and is thus safe as-is or with various module systems.  Stand-alone example:\n\n```html\n\u003cscript src=\"longwebsocket.min.js\"\u003e\u003c/script\u003e\n...\n\u003cscript type=\"text/javascript\"\u003e\u003c!--\n  var ws = new LongWebSocket();\n  ...\n// --\u003e\u003c/script\u003e\n```\n\n### Node.JS and client-side (CommonJS)\n\n```sh\nnpm install longwebsocket --save\n```\n\nIn Node.JS or if you're using Browserify to bundle CommonJS modules together for client-side use, you can choose whichever name you'd like, although in this document we'll assume `LongWebSocket`.  For example:\n\n```js\nvar LongWebSocket = require('longwebsocket');\nvar ws = new LongWebSocket();\n...\n```\n\n### Usage example\n\n```js\nvar ws = new LongWebSocket({\n  onmessage: function(msg) {\n    console.log('Received: ' + msg);\n    ws.send(msg);  // Simple echo\n  },\n  onopen: function() {\n    console.log(\"There we go, we're online now, we can send!\");\n  },\n  onclose: function() {\n    console.log(\"Offline! Not for long, I'm sure...\");\n  }\n});\n```\n\n## API\n\n### ws = new LongWebSocket([*options*])\n\nIf supplied, the `options` is an object which may include any combination of:\n\n**url:** If omitted, a WebSocket will be attempted at the current location's host and port.  HTTPS will also correctly yield a WSS socket.\n\n**protocols:** Passed directly to WebSocket.\n\n**onmessage:** Callback for you to receive messages as they arrive.  It will be given a single argument containing the message itself.\n\n**onopen:** Called each time the WebSocket becomes available for sending, if specified.\n\n**onclose:** Called each time the WebSocket gets closed (including by you).\n\nAll arguments are optional, but only a specific set of combinations are allowed: a single argument must be `onmsg`.  If there are more than one argument, there may be up to 2 strings left of `onmsg` which will be processed as either `(protocols)` or `(url, protocols)` according to count.  To the right of `onmsg` the immediate next is considered `onopen`, then `onclose`.\n\n### ws.send(msg)\n\nSend message `msg` to the other end.  Any error would bubble up from the underlying WebSocket.\n\n### ws.close([*code*[, *reason*]])\n\nClose the WebSocket and do not attempt to reconnect it.  Arguments are passed directly to WebSocket.\n\n### ws.open()\n\nRe-open a closed LongWebSocket.  Previously defined options are retained.\n\n## MIT License\n\nCopyright (c) 2016 Stephane Lavergne \u003chttps://github.com/vphantom\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvphantom%2Flongwebsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvphantom%2Flongwebsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvphantom%2Flongwebsocket/lists"}