wasmtime icon indicating copy to clipboard operation
wasmtime copied to clipboard

wasi-http: add the port to authority when opening a TCP connection

Open iawia002 opened this issue 1 year ago • 6 comments

#8563 removes the port from the authority, it makes the target address cannot be correctly resolved when opening a TCP connection. This results in that if we want to send an HTTP request in the wasi component, an error ErrorCode::ConnectionRefused will be reported directly. The underlying error is invalid socket address:

Screenshot 2024-05-21 at 17 21 56

/cc @alexcrichton @elliottt

iawia002 avatar May 21 '24 10:05 iawia002

What if the program explicitly specified a port different from 80 or 443? Wouldn't this change break that by creating a nonsensical address like 127.0.0.1:1234:80 when trying to request http://127.0.0.1:1234/some_page?

bjorn3 avatar May 21 '24 10:05 bjorn3

What if the program explicitly specified a port different from 80 or 443? Wouldn't this change break that by creating a nonsensical address like 127.0.0.1:1234:80 when trying to request http://127.0.0.1:1234/some_page?

Indeed, I didn't consider that. I will update it again.

iawia002 avatar May 21 '24 10:05 iawia002

Does this mean that default_send_request_handler basically previously didn't work by default? If so, that seems bad!

Would you be up for adding a test for this?

alexcrichton avatar May 21 '24 18:05 alexcrichton

Does this mean that default_send_request_handler basically previously didn't work by default? If so, that seems bad!

Would you be up for adding a test for this?

I think that that is the case, could we have a fix like this one on a 21.0.1 version?

morenol avatar May 21 '24 20:05 morenol

Yeah, definitely seems bad enough for a point release! Would you be up for adding a test here? perhaps fetching something like example.com or similar? That'll be flaky over time but we can try to add various exceptions for possible errors due to flakiness over time.

alexcrichton avatar May 21 '24 20:05 alexcrichton

I have added a test for this case, following @elliottt's advice in https://github.com/bytecodealliance/wasmtime/pull/8676#discussion_r1609131895, PTAL @alexcrichton @elliottt

iawia002 avatar May 22 '24 02:05 iawia002

Could you remove the use of ssl in your test program? CI failed because it's not supported on riscv64.

elliottt avatar May 22 '24 15:05 elliottt

Ah I went ahead and just pushed up a commit to ignore s390x/riscv64, I don't think it's too critical to get all the architectures tested here

alexcrichton avatar May 22 '24 15:05 alexcrichton