second-state / wasmedge-quickjs

A high-performance, secure, extensible, and OCI-complaint JavaScript runtime for WasmEdge.
Apache License 2.0
491 stars 59 forks source link

Http server connect issue #23

Open chenyukang opened 2 years ago

chenyukang commented 2 years ago

I tried with the steps, and found the http server demo can not work properly:

image

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: image

~/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)
chenyukang commented 2 years ago

FYI: https://github.com/second-state/dapr-wasm/issues/17

Dapr will try to check API when starting up:

image

juntao commented 2 years ago

Could the Dapr check sends a "proper" http request with a header? The telnet request is technically not http.

chenyukang commented 2 years ago

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
chenyukang commented 2 years ago

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.

juntao commented 2 years ago

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.

chenyukang commented 2 years ago

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 :)

juntao commented 2 years ago

@chenyukang Do both curl and telnet fail on your machine if you do not have nohup?

chenyukang commented 2 years ago

@chenyukang Do both curl and telnet fail on your machine if you do not have nohup?

Yes