{"id":13600297,"url":"https://github.com/microsoft/wsplice","last_synced_at":"2025-08-05T04:19:56.589Z","repository":{"id":57646274,"uuid":"104686046","full_name":"microsoft/wsplice","owner":"microsoft","description":":twisted_rightwards_arrows: A fast websocket multiplexer","archived":false,"fork":false,"pushed_at":"2023-06-27T13:03:57.000Z","size":27,"stargazers_count":28,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-08T10:12:30.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/microsoft.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-25T00:24:53.000Z","updated_at":"2025-02-12T06:37:39.000Z","dependencies_parsed_at":"2024-06-20T09:29:20.227Z","dependency_job_id":"892cb16e-4a92-4113-b259-6981b984052b","html_url":"https://github.com/microsoft/wsplice","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fwsplice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fwsplice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fwsplice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fwsplice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/wsplice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248301449,"owners_count":21080894,"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","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-08-01T18:00:35.296Z","updated_at":"2025-04-10T21:31:30.981Z","avatar_url":"https://github.com/microsoft.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# wsplice [![Build Status](https://travis-ci.org/mixer/wsplice.svg?branch=master)](https://travis-ci.org/mixer/wsplice)\n\n`wsplice` is a websocket multiplexer, allowing you to connect to multiple remote hosts though a single websocket.\n\n### Usage\n\nDownload a binary from the [Releases page](https://github.com/mixer/wsplice/releases). You can then run it from the command line. `wsplice` can be configured to use client certification authentication, and/or an allowlist of remote hostnames it's allowed to connect to.\n\n```bash\n# Run a publicly accessible instance with client cert auth\n./wsplice --tls-cert=my-cert.pem \\\n    --tls-key=my-key.pem \\\n    --tls-ca=my-ca.pem \\\n    --listen=0.0.0.0:3000\n\n# Omit the CA cert to run it over TLS, and allow it to connect\n# to example.com and ws.example.com\n./wsplice --tls-cert=my-cert.pem \\\n    --tls-key=my-key.pem \\\n    --allowed-hostnames=\"example.com ws.example.com\"\n```\n\n### Protocol\n\nWebsocket frames are prefixed with two bytes, as a big endian uint16, to describe who that message goes to. The magic control index is `[0xff, 0xff]`, which is a simple JSON RPC protocol. To connect to another server, you might do something like this in Node.js:\n\n```js\nconst payload = Buffer.concat([\n    Buffer.from([0xff, 0xff]),\n    Buffer.from(JSON.stringify({\n        id: 42,\n        type: \"method\",\n        method: \"connect\",\n        params: {\n            url: \"ws://example.com\",\n            headers: { /* ... */ }, // optional\n            subprotocols: [/* ... */], // optional\n        }\n    }))\n]);\n\nwebsocket.write(payload);\n```\n\nThe response is a JSON object like:\n\n```json\n{\n  \"id\": 42,\n  \"type\": \"reply\",\n  \"result\": {\n    \"index\": 0\n  }\n}\n```\n\nIn this case the socket index is 0. You can send messages to that websocket by prefixing the messages with `0`, encoded as a big endian uint16, and likewise wsplice will proxy and prefix messages that it gets from that server with the same. All frames, with the exception of `ping` and `pong` frames (which are handled automatically for you) will be proxied.\n\nOnce the client disconnects, the wsplice will call `onSocketDisconnect`. For example:\n\n```json\n{\n  \"id\": 0,\n  \"type\": \"method\",\n  \"method\": \"onSocketDisconnect\",\n  \"params\": {\n    \"code\": 4123,\n    \"message\": \"The socket close reason, if any\",\n    \"index\": 0\n  }\n}\n```\n\n### Performance\n\n`wsplice` spends most time (upwards of 90%) handling network reads/writes; performance is generally bounded by how much data your operating system's kernel and send or receive from a single connection.\n\n| Throughput  | payload=32B | payload=128B | payload=1024B | payload=4098B |\n|-------------|-------------|--------------|---------------|---------------|\n| clients=32  | 231 mbps    | 235 mbps     | 2940 mbps     | 11200 mbps    |\n| clients=128 | 327 mbps    | 333 mbps     | 2520 mbps     | 14600 mbps    |\n| clients=512 | 46.3 mbps   | 533 mbps     | 3570 mbps     | 11200 mbps    |\n| **Latency** |             |              |               |               |\n| clients=32  | 5.6μs       | 4.6μs        | 5.4μs         | 7.4μs         |\n| clients=128 | 4.7μs       | 5.2μs        | 5.7μs         | 5.7μs         |\n| clients=512 | 3.7μs       | 4.0μs        | 5.2μs         | 7.1μs         |\n\nThese measurements were taken on an B8 Azure VM running Ubuntu 16.04, using the binary in `./cmd/bench`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fwsplice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fwsplice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fwsplice/lists"}