{"id":15611582,"url":"https://github.com/boxdot/tonic-ws-transport","last_synced_at":"2025-04-15T01:43:55.746Z","repository":{"id":46568382,"uuid":"312223976","full_name":"boxdot/tonic-ws-transport","owner":"boxdot","description":"gRPC over websocket (in browser and natively)","archived":false,"fork":false,"pushed_at":"2024-08-28T09:21:21.000Z","size":100,"stargazers_count":29,"open_issues_count":2,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T13:44:34.324Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boxdot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-12T09:13:05.000Z","updated_at":"2025-02-26T18:26:02.000Z","dependencies_parsed_at":"2024-01-12T12:07:28.628Z","dependency_job_id":"73932981-3d1c-4bfc-a8c1-2a48d34e2828","html_url":"https://github.com/boxdot/tonic-ws-transport","commit_stats":{"total_commits":45,"total_committers":2,"mean_commits":22.5,"dds":0.1777777777777778,"last_synced_commit":"f9fc7cb603f6426e18267d580a96182f2882a59f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxdot%2Ftonic-ws-transport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxdot%2Ftonic-ws-transport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxdot%2Ftonic-ws-transport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boxdot%2Ftonic-ws-transport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boxdot","download_url":"https://codeload.github.com/boxdot/tonic-ws-transport/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991526,"owners_count":21194893,"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-10-03T06:05:34.518Z","updated_at":"2025-04-15T01:43:55.730Z","avatar_url":"https://github.com/boxdot.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tonic-ws-transport\n![CI][ci-badge]\n\nAn experimental library to enable gRPC tunnelling over a web socket. In\nparticular, it makes it possible to use streaming gRPC in any browser.\n\nThis requires a patched `tonic` which support WASM as compilation target. See\n`Cargo.toml` for the patches.\n\n## Why\n\nWe would like to use gRPC in browsers that do not support bare TCP connections\nand HTTP/2. For that, we use WebSockets to emulate TCP and use HTTP/2\nimplementation from tonic/hyper/h2. This is especially useful for streaming\ngRPC. Note that gRPC-web does not support client to server streaming:\n~~[grpc-web#815](https://github.com/grpc/grpc-web/issues/815)~~\n[grpc-web#1205](https://github.com/grpc/grpc-web/issues/1205).\n\n## Example\n\nRun server example in native environment:\n\n```bash\ncargo run --bin server\n```\n\nThen compile wasm and open it in browser:\n\n```bash\ncd examples/wasm-client\ncargo install wasm-pack\nwasm-pack build --target web\npython3 -m http.server\n# open http://0.0.0.0:8000/ in browser\n```\n\n## Usage\nYou can currently use this as a git dependency. You will need to enable the `tokio_unstable` config flag for tonic to compile.\nUpdate your `.cargo/config.toml`:\n```toml\n[build]\n# This is necessary because tonic needs the tower `make` feature which in turn needs tokios io-std feature which doesn't\n# compile on wasm unless tokio_unstable is active\nrustflags = [\"--cfg=tokio_unstable\"]\n```\n\n## How\n\n`tonic` has a very flexible API which allows to use custom connectors. A\nconnector establishes a connection when the client tries to connect to an\nendpoint. The server listens on a TCP socket as usual, and uses the same\nconnection type when a TCP connection is established.\n\nIn our cases, instead of connecting to an HTTP resource, we connect to a web\nsocket, which is supported in native environment but also in all web browsers.\nThe web socket connector returns a web socket connection which tunnels all\ntraffic via web socket data frames. In Rust words, it implements\n[AsyncWrite](https://docs.rs/tokio/latest/tokio/io/trait.AsyncWrite.html) and\n[AsyncRead](https://docs.rs/tokio/latest/tokio/io/trait.AsyncRead.html). The\nconnection is then used in the `tonic` transport instead of the default TCP\nconnection.\n\nFinally, the `tonic` client is compiled to WASM. The HTTP/2 (`hyper`) and gRPC\nclient (`tonic`) implementations are running in WASM. Since web sockets are\nstreaming by nature, we support all flavors of gRPC, in particular,\n(bidirectional) streaming.\n\nThe name of this repository is actually a misnomer: technically, the transport\nis not `tonic` related. It tunnels any bytes through a web socket, and so can be\nused for any binary protocol as transport layer.\n\n## License\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n   http://www.apache.org/licenses/LICENSE-2.0)\n * MIT License ([LICENSE-MIT](LICENSE-MIT) or\n   http://opensource.org/licenses/MIT)\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in this document by you, as defined in the Apache-2.0 license,\nshall be dual licensed as above, without any additional terms or conditions.\n\n[ci-badge]: https://github.com/boxdot/gurk-rs/workflows/CI/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboxdot%2Ftonic-ws-transport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboxdot%2Ftonic-ws-transport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboxdot%2Ftonic-ws-transport/lists"}