{"id":13609337,"url":"https://github.com/bortexz/resocket","last_synced_at":"2025-10-22T00:10:12.353Z","repository":{"id":58129081,"uuid":"530142375","full_name":"bortexz/resocket","owner":"bortexz","description":"JDK11 Clojure WebSocket client with core.async API","archived":false,"fork":false,"pushed_at":"2022-12-17T11:45:47.000Z","size":21,"stargazers_count":28,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-22T00:07:20.624Z","etag":null,"topics":["clojure","core-async","jdk11","websocket","websocket-client"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bortexz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-29T09:03:48.000Z","updated_at":"2025-03-05T15:29:03.000Z","dependencies_parsed_at":"2023-01-29T17:15:14.088Z","dependency_job_id":null,"html_url":"https://github.com/bortexz/resocket","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bortexz/resocket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bortexz%2Fresocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bortexz%2Fresocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bortexz%2Fresocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bortexz%2Fresocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bortexz","download_url":"https://codeload.github.com/bortexz/resocket/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bortexz%2Fresocket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280354909,"owners_count":26316566,"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-10-21T02:00:06.614Z","response_time":58,"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":["clojure","core-async","jdk11","websocket","websocket-client"],"created_at":"2024-08-01T19:01:34.212Z","updated_at":"2025-10-22T00:10:12.316Z","avatar_url":"https://github.com/bortexz.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"# resocket\n[![Clojars Project](https://img.shields.io/clojars/v/io.github.bortexz/resocket.svg)](https://clojars.org/io.github.bortexz/resocket)[![Cljdoc](https://cljdoc.org/badge/io.github.bortexz/resocket)](https://cljdoc.org/d/io.github.bortexz/resocket)\n\nJDK11 Clojure WebSocket client with core.async API\n\n## Features\n\n- core.async API with `input` and `output` channels for receiving/sending messages, and `closed` promise-chan with details about the closing of the connection.\n- Automatically send `ping` frames to the server at given intervals, abort connections that do not `pong` within a certain timeout.\n- Close a connection by closing `output` channel, abort within a certain timeout if `on-close` is not received from the server.\n- Specify `input` and `output` parsers to take/put your preferred data structure on the channels (maps, vecs, ...) and use the parser for json/edn parsing, etc.\n- Minimal dependencies, just `clojure` and `core.async`.\n- `reconnector` process to create new connections when the previous ones have been closed, returning a core.async `connections` channel to take new connections from.\n- Small codebase, around ~300 LOC docstrings included.\n\n## Install\n### **Leiningen/Boot**\n```clojure\n[io.github.bortexz/resocket \"0.1.0\"]\n```\n\n### **Clojure CLI/deps.edn**\n```clojure\nio.github.bortexz/resocket {:mvn/version \"0.1.0\"}\n```\n\n## Usage\n\nSee the [docs](https://cljdoc.org/d/io.github.bortexz/resocket) for more detailed information about all the options available.\n\n### Quick introduction\n\nConnection:\n```Clojure\n(require '[bortexz.resocket :as resocket])\n\n(let [{:keys [input output closed error]} (a/\u003c!! (resocket/connection \"ws://\u003cservice\u003e\" {}))]\n    (when-not error\n      (a/\u003c!! input) ;; Take new messages\n      (a/\u003e!! output \"Hi from client\") ;; Send messages\n      (a/close! output) ;; Close connection\n      (a/\u003c!! closed)) ;; {:close-type :on-close :status 1000 :description \"\"}\n    )\n```\n\nReconnector:\n```Clojure\n(let [{:keys [connections close closed?]} (resocket/reconnector {:get-url (constantly \"ws://\u003cservice\u003e\")})]\n    (a/go-loop []\n      (when-let [conn (a/\u003c! connections)] ;; get new connections until reconnector closed\n        (loop []\n          (when-let [v (a/\u003c! (:input conn))]\n            ;; Process messages\n            (recur)))\n        (recur)))\n    ;; Somewhere else, when tired of receiving new connections\n    (a/close! close) ; Closes current connection (if any) and the reconnector\n\n    ;; Listen to closed? in a different place than the connections handler\n    (when (a/\u003c! closed?) \"Reconnector has been closed.\")\n  )\n```\n\n## Credits\n- [hato](https://github.com/gnarroway/hato) as this library borrows some code from hato's websocket client.\n\n## License\n\nCopyright © 2022 Alberto Fernandez\n\nDistributed under the Eclipse Public License version 1.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbortexz%2Fresocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbortexz%2Fresocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbortexz%2Fresocket/lists"}