dotnet / dotnet-wasi-sdk

An SDK for building .NET projects as standalone WASI-compliant modules
MIT License
279 stars 12 forks source link

HttpClient not working #11

Open stanac opened 1 year ago

stanac commented 1 year ago

Simple console app using .NET 7 with Wasi.Sdk 0.1.3-preview.10012 :

HttpClient c = new HttpClient();
HttpResponseMessage r = await c.GetAsync("https://github.com/");

Console.WriteLine($"Response status: {(int)r.StatusCode}");
Console.WriteLine("Content length:" + r.Content.ReadAsStream().Length);

Tried running using wastime 6.0.0 with: wasmtime run .\myapp.wasm and wasmtime run .\myapp.wasm --wasi-modules wasi-common, in both cases following error is printed:

[wasm_trace_logger] cant resolve internal call to "Interop/Runtime::BindJSFunction" (tested without signature also)

Your mono runtime and class libraries are out of sync.
The out of sync library is: System.Runtime.InteropServices.JavaScript.dll

When you update one from git you need to update, compile and install
the other too.
Do not report this as a bug unless you're sure you have updated correctly:
you probably have a broken mono install.
If you see other errors or faults after this message they are probably related
and you need to fix your mono install first.

Unhandled Exception:
System.MissingMethodException:  assembly:<unknown assembly> type:<unknown type> member:(null)
   at System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunctionImpl(String functionName, String moduleName, ReadOnlySpan`1 signatures)
   at System.Runtime.InteropServices.JavaScript.JSFunctionBinding.BindJSFunction(String functionName, String moduleName, ReadOnlySpan`1 signatures)
   at System.Net.Http.BrowserHttpInterop.SupportsStreamingResponse()
   at System.Net.Http.BrowserHttpHandler..cctor()
Terricide commented 1 year ago

I don't think the wasi spec supports outbound networking yet.