Stream: general

Topic: ✔ Enable outgoing HTTP requests when using wasmtime as a ...


view this post on Zulip Kyle Gray (Feb 28 2024 at 00:50):

I'm trying to create a Python component that makes an outbound HTTP request using a Rust host. I've gotten the component built, but it hangs when executing the outbound HTTP request. I'm guessing this is because I haven't hooked up Tokio inside my Rust host.

I've been trying to repurpose code from https://github.com/bytecodealliance/wasmtime/blob/v17.0.1/src/commands/serve.rs to make it work. My question: Does wasmtime_wasi_http have a helper function to make this work?

Haven't posted here very much, so please let me know if there's a better place for this to go.

view this post on Zulip Joel Dice (Feb 28 2024 at 15:28):

I'm not sure what would be causing it to hang, but if you can push what you have to a public repo, I can try to debug it.

view this post on Zulip Kyle Gray (Feb 28 2024 at 17:42):

Pushed my code here (https://github.com/kyleconroy/compontentize-py-http) which shows the issue. Let me know if you can't get it to build.

Contribute to kyleconroy/compontentize-py-http development by creating an account on GitHub.

view this post on Zulip Joel Dice (Feb 28 2024 at 18:08):

Switching from async-std to tokio fixed it: https://github.com/kyleconroy/compontentize-py-http/pull/1. Given that wasmtime-wasi and wasmtime-wasi-http rely on tokio, I doubt there's a way to make embeddings work with other executors for the time being without some extensive changes.

wasmtime-wasi and wasmtime-wasi-http both rely on tokio, so I'm not sure it's possible to make them work on a different runtime. Switching to tokio fixes the hang when making an outgoing request. ...

view this post on Zulip Kyle Gray (Feb 28 2024 at 18:09):

Thanks Joel. I'm a bit new to Rust so I wouldn't have ever caught this.

view this post on Zulip Joel Dice (Feb 28 2024 at 18:10):

Yeah, the whole "how to I choose an async executor?" question trips everybody up.

view this post on Zulip Notification Bot (Feb 28 2024 at 18:40):

Kyle Gray has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC