wasmedge-quickjs
wasmedge-quickjs copied to clipboard
Http server connect issue
I tried with the steps, and found the http server demo can not work properly:

Then send request will failed:
coderscat@MININT-ODP168:~/dapr-wasm$ curl -d "WasmEdge" -X POST http://127.0.0.1:8000
curl: (7) Failed to connect to 127.0.0.1 port 8000: Connection refused
If we try to telnet, it will crash with an error:

~/wasmedge-quickjs/example_js$ wasmedge --dir .:. ../target/wasm32-wasi/release/wasmedge_quickjs.wasm http_server_demo.js
listen on 0.0.0.0:8000
InternalError: Error(TrackableError { kind: InvalidInput, cause: Some(Cause("assertion failed: `left == right`; assertion failed: `(left == right)` (left: `'\\r'`, right: `' '`)")), history: History([Location { module_path: "httpcodec::method", file: "/home/coderscat/.c
at accept (native)
at <anonymous> (http_server_demo.js:15)
FYI: https://github.com/second-state/dapr-wasm/issues/17
Dapr will try to check API when starting up:

Could the Dapr check sends a "proper" http request with a header? The telnet request is technically not http.
Could the Dapr check sends a "proper" http request with a header? The telnet request is technically not http.
I know the reason now.
We must run the command nohup,otherwise we can not connect to server successfully.
cat@MININT-ODP168:~/code/wasmedge-quickjs/example_js$ nohup wasmedge --dir .:. ../target/wasm32-wasi/release/wasmedge_quickjs.wasm http_server_demo.js &
[1] 28385
I don't know the root cause, why do we have this limitation?
wasmedge --dir .:. ../target/wasm32-wasi/release/wasmedge_quickjs.wasm http_server_demo.js
can not start the server properly.
Just to make sure -- if you do not use nohup, you will need to start the server in one terminal and run the HTTP client in another terminal window.
Just to make sure -- if you do not use
nohup, you will need to start the server in one terminal and run the HTTP client in another terminal window.
I used multiple terminals to test, I guess there is a potential issue we haven't understood :)
@chenyukang Do both curl and telnet fail on your machine if you do not have nohup?
@chenyukang Do both
curlandtelnetfail on your machine if you do not havenohup?
Yes