wasmedge-quickjs icon indicating copy to clipboard operation
wasmedge-quickjs copied to clipboard

Http server connect issue

Open chenyukang opened this issue 4 years ago • 8 comments

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 avatar Oct 22 '21 11:10 chenyukang

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

Dapr will try to check API when starting up:

image

chenyukang avatar Oct 22 '21 11:10 chenyukang

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

juntao avatar Oct 23 '21 20:10 juntao

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 avatar Nov 22 '21 11:11 chenyukang

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.

chenyukang avatar Nov 22 '21 12:11 chenyukang

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.

juntao avatar Nov 22 '21 17:11 juntao

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 avatar Nov 23 '21 03:11 chenyukang

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

juntao avatar Nov 23 '21 04:11 juntao

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

Yes

chenyukang avatar Nov 23 '21 04:11 chenyukang