{"id":48791925,"url":"https://github.com/aamcrae/rust-wasm-grpc","last_synced_at":"2026-04-13T20:31:44.036Z","repository":{"id":293161494,"uuid":"983132774","full_name":"aamcrae/rust-wasm-grpc","owner":"aamcrae","description":"Example of Rust, WASM, gRPC and web workers","archived":false,"fork":false,"pushed_at":"2025-12-30T02:13:27.000Z","size":38,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-02T11:29:32.790Z","etag":null,"topics":["grpc","rust","wasm","web-worker"],"latest_commit_sha":null,"homepage":"","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/aamcrae.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-13T23:44:57.000Z","updated_at":"2025-12-30T02:13:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"0545ba45-cf61-42b9-adc5-56172922b316","html_url":"https://github.com/aamcrae/rust-wasm-grpc","commit_stats":null,"previous_names":["aamcrae/rust-wasm-grpc"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aamcrae/rust-wasm-grpc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aamcrae%2Frust-wasm-grpc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aamcrae%2Frust-wasm-grpc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aamcrae%2Frust-wasm-grpc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aamcrae%2Frust-wasm-grpc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aamcrae","download_url":"https://codeload.github.com/aamcrae/rust-wasm-grpc/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aamcrae%2Frust-wasm-grpc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31770718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T20:17:16.280Z","status":"ssl_error","status_checked_at":"2026-04-13T20:17:08.216Z","response_time":93,"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":["grpc","rust","wasm","web-worker"],"created_at":"2026-04-13T20:31:42.283Z","updated_at":"2026-04-13T20:31:44.014Z","avatar_url":"https://github.com/aamcrae.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust WASM gRPC using a web worker\n\nThere are very few examples of Rust WASM clients that\nuse gRPC, and not any I have found that use web workers, so when\nI figured out how to put all these together, I thought it would be useful\nto publish a working example.\n\nThis example application combines Rust, WASM, gRPC, and web workers\nall in a single working system (a very simple joke streaming service).\n\n## Prerequisites\n\nEnsure that the following items are installed:\n\n - [Protobuf compiler](http://grpc.io/docs/protoc-installation)\n - [wasm-bindgen](https://crates.io/crates/wasm-bindgen)\n - WASM Rust toolchain - use ```rustup target add wasm32-unknown-unknown```\n\n## Building and running using Docker\n\nA docker image can be built as:\n\n```\ndocker build --tag aamcrae/jokes:latest -f Dockerfile .\n```\n\nAnd run as:\n\n```\ndocker compose up\n```\n\nThen navigate a browser tab to ```localhost:8400```\n\n## Building and running manually.\n\n```build.sh``` is a shell script that will build all the binaries, and install\nthe WASM files into the ```www``` directory.\n\nRun the server via:\n\n```\ncargo run -r --bin server\n```\n\nOpen a browser tab and navigate to the URL displayed.\n\nThe server has a number of arguments that can be set to change the default port numbers etc.\nUse ```cargo run -r --bin server -- --help``` to get help on the arguments.\n\n## Points of Interest\n\nThe application is a simple streaming service that demonstrates:\n\n - Rust-based WASM modules, loaded by a simple web server and started by a script.\n - [Web-gRPC](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md).  Due to limitations in the browser environment, there are differences between Web-gRPC and the full gRPC-over-HTTP2 protocol. This limits the streaming to server -\u003e client; bi-directional streaming or client -\u003e server streaming are not supported.\n - Web workers. The client offloads the gRPC handling to a WASM [web worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) via [gloo-worker](https://docs.rs/gloo-worker/latest/gloo_worker). The protobuf decoding and server connection is managed completely within the web worker.\n\nThe web-worker/client interface operates by messages being sent to and from the worker, using the gloo-worker framework.\nInternally, the framework serializes the messages using [bincode](https://docs.rs/bincode/latest/bincode/),\nbut I found with larger or more complex structs, it would often panic, so to work around this,\nthe messages are explicitly encoded and decoded via bincode before being sent, which seems to work much more reliably.\n\nFor a more complex system, messages from the client to the web worker could initiate separate RPCs to the server.\nPotentially, more web workers could be used to offload work from the client.\nThese exercises are left to the reader.\n\n## Supporting crates\n\nThis example relies on the following crates:\n\n - [prost](https://github.com/tokio-rs/prost)\n - [tonic-web-wasm-client](https://crates.io/crates/tonic-web-wasm-client)\n - [gloo-worker](https://docs.rs/gloo-worker/latest/gloo_worker)\n - [tonic](https://docs.rs/tonic/latest/tonic/)\n - [tokio](https://tokio.rs/)\n - [devserver](https://crates.io/crates/devserver)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faamcrae%2Frust-wasm-grpc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faamcrae%2Frust-wasm-grpc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faamcrae%2Frust-wasm-grpc/lists"}