Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws client demo couldn't connect to server #3125

Closed
qdztxc opened this issue Apr 30, 2024 · 7 comments
Closed

ws client demo couldn't connect to server #3125

qdztxc opened this issue Apr 30, 2024 · 7 comments

Comments

@qdztxc
Copy link

qdztxc commented Apr 30, 2024

I try to do a ws client/server pair test but it doesn't work.
minimal-ws-client-echo and minimal-ws-server-echo, client failed with

[2024/04/30 13:19:33:7846] I: rops_handle_POLLIN_netlink: RTM 3
[2024/04/30 13:19:33:7846] I: rops_handle_POLLIN_netlink: *** Unknown RTM_3
[2024/04/30 13:19:33:7846] I: lws_http_client_socket_service: proxy connection extablished
[2024/04/30 13:19:33:7846] I: lws_http_client_socket_service: HANDSHAKE2: [wsicli|0|WS/h1/default/localhost]: sending headers (wsistate 0x10000203), w sock 6
[2024/04/30 13:19:33:8846] I: lws_state_transition_steps: INITIALIZED -> OPERATIONAL
[2024/04/30 13:19:35:4028] I: [wsicli|0|WS/h1/default/localhost]: lws_ssl_capable_read_no_ssl: error on reading from skt : 0, errno 0
[2024/04/30 13:19:35:4028] I: lws_http_client_socket_service: closing conn at LWS_CONNMODE...SERVER_REPLY, [wsicli|0|WS/h1/default/localhost], state 0x20b
[2024/04/30 13:19:35:4028] I: reason: read failed
[2024/04/30 13:19:35:4028] E: CLIENT_CONNECTION_ERROR: read failed
[2024/04/30 13:19:35:4028] I: [wsicli|0|WS/h1/default/localhost]: __lws_close_free_wsi: caller: cbail3
[2024/04/30 13:19:35:4029] I: [wsicli|0|WS/h1/default/localhost]: __lws_close_free_wsi: real just_kill_connection: sockfd 6
[2024/04/30 13:19:35:4029] I: [wsicli|0|WS/h1/default/localhost]: __lws_close_free_wsi: cce=1
[2024/04/30 13:19:35:4030] I: rops_destroy_role_h1: ah det due to close
[2024/04/30 13:19:35:4030] I: __lws_header_table_detach: [wsicli|0|WS/h1/default/localhost]: ah 0x55c343ec2240 (tsi=0, count = 1)
[2024/04/30 13:19:35:4030] I: __lws_header_table_detach: nobody usable waiting
[2024/04/30 13:19:35:4030] I: _lws_destroy_ah: freed ah 0x55c343ec2240 : pool length 0
[2024/04/30 13:19:35:4030] I: __lws_header_table_detach: [wsicli|0|WS/h1/default/localhost]: ah 0x55c343ec2240 (tsi=0, count = 0)
[2024/04/30 13:19:35:4030] N: __lws_lc_untag: -- [wsicli|0|WS/h1/default/localhost] (0) 1.619s
[2024/04/30 13:19:35:4030] I: lws_context_destroy: destroy_state 0
[2024/04/30 13:19:35:4030] I: lws_context_destroy: starting context destroy flow
[2024/04/30 13:19:35:4031] I: [vh|1|default||-1]: lws_context_destroy: start close
[2024/04/30 13:19:35:4031] I: [vh|1|default||-1]: lws_vhost_destroy1:
[2024/04/30 13:19:35:4031] I: [wsi|0|pipe]: __lws_close_free_wsi: caller: ctx destroy
[2024/04/30 13:19:35:4031] I: [wsi|0|pipe]: __lws_close_free_wsi: real just_kill_connection: sockfd 4
[2024/04/30 13:19:35:4031] I: [wsi|0|pipe]: __lws_close_free_wsi: cce=0
[2024/04/30 13:19:35:4031] N: __lws_lc_untag: -- [wsi|0|pipe] (0) 1.621s
[2024/04/30 13:19:35:4031] I: [vh|0|netlink]: __lws_close_free_wsi: caller: ctx destroy
[2024/04/30 13:19:35:4031] I: [vh|0|netlink]: __lws_close_free_wsi: real just_kill_connection: sockfd 5
[2024/04/30 13:19:35:4031] I: [vh|0|netlink]: __lws_close_free_wsi: cce=0
[2024/04/30 13:19:35:4032] N: __lws_lc_untag: -- [vh|0|netlink] (1) 1.621s
[2024/04/30 13:19:35:4032] I: lws_context_destroy: manually destroying pts
[2024/04/30 13:19:35:4032] I: lws_context_destroy: PT_WAIT_ALL_DESTROYED: 0 alive
[2024/04/30 13:19:35:4032] N: __lws_lc_untag: -- [vh|1|default||-1] (0) 1.620s
[2024/04/30 13:19:35:4032] I: lws_context_destroy: pt destroy 0
[2024/04/30 13:19:35:4033] I: lws_state_transition_steps: POLICY_INVALID -> DESTROYING
[2024/04/30 13:19:35:4033] I: lws_context_destroy: pt 0 fully destroyed
[2024/04/30 13:19:35:4033] U: Completed 3 failed

@qdztxc
Copy link
Author

qdztxc commented Apr 30, 2024

Then I try
./bin/lws-minimal-ws-server -s
./bin/lws-minimal-ws-client-ping --server localhost --port 7681

It failed with
[2024/04/30 13:22:02:7001] N: __lws_lc_tag: ++ [wsicli|1|WS/h1/default/localhost] (1)
[2024/04/30 13:22:02:7001] I: lws_header_table_attach: [wsicli|1|WS/h1/default/localhost]: ah (nil) (tsi 0, count = 0) in
[2024/04/30 13:22:02:7001] I: _lws_create_ah: created ah 0x561d2f646d10 (size 4096): pool length 1
[2024/04/30 13:22:02:7002] I: lws_header_table_attach: did attach wsi [wsicli|1|WS/h1/default/localhost]: ah 0x561d2f646d10: count 1 (on exit)
[2024/04/30 13:22:02:7002] I: [wsicli|1|WS/h1/default/localhost]: lws_client_connect_2_dnsreq: lookup 127.0.0.1:6721
[2024/04/30 13:22:02:7002] I: [wsicli|1|WS/h1/default/localhost]: lws_getaddrinfo46: getaddrinfo '127.0.0.1' says 0
[2024/04/30 13:22:02:7002] I: [wsicli|1|WS/h1/default/localhost]: lws_sort_dns: sort_dns: 0x561d2f648130
[2024/04/30 13:22:02:7002] I: [wsicli|1|WS/h1/default/localhost]: lws_sort_dns: unsorted entry (af 2) 127.0.0.1
[2024/04/30 13:22:02:7002] I: _lws_route_est_outgoing: gw hit
[2024/04/30 13:22:02:7002] I: [wsicli|1|WS/h1/default/localhost]: lws_sort_dns_dump: 1: (2)127.0.0.1, gw (0)(unset), idi: 1, lbl: 0, prec: 0
[2024/04/30 13:22:02:7002] I: [wsicli|1|WS/h1/default/localhost]: lws_client_connect_3_connect: peer_route_uidx 8
[2024/04/30 13:22:02:7003] N: [wsicli|1|WS/h1/default/localhost]: lws_client_connect_3_connect: trying 127.0.0.1
[2024/04/30 13:22:02:7004] I: [wsicli|1|WS/h1/default/localhost]: lws_client_connect_3_connect: source ads 127.0.0.1
[2024/04/30 13:22:02:7004] I: [wsicli|1|WS/h1/default/localhost]: lws_client_connect_4_established: going via proxy
[2024/04/30 13:22:02:7007] I: lws_http_client_socket_service: proxy connection extablished
[2024/04/30 13:22:02:7008] I: lws_tls_restrict_borrow: 0 -> 1
[2024/04/30 13:22:02:7008] I: lws_tls_reuse_session: no existing session for default_localhost_6721
[2024/04/30 13:22:02:7009] I: h1 client conn using alpn list 'h2;http/1.1'
[2024/04/30 13:22:04:2820] I: lws_tls_client_connect: n -1, m 5, errno 0
[2024/04/30 13:22:04:2821] I: lws_tls_restrict_return_handshake: 1 -> 0
[2024/04/30 13:22:04:2821] I: lws_http_client_socket_service: closing conn at LWS_CONNMODE...SERVER_REPLY, [wsicli|1|WS/h1/default/localhost], state 0x204
[2024/04/30 13:22:04:2821] I: reason: connect SYSCALL 0
[2024/04/30 13:22:04:2821] E: CLIENT_CONNECTION_ERROR: connect SYSCALL 0
[2024/04/30 13:22:04:2821] I: [wsicli|1|WS/h1/default/localhost]: __lws_close_free_wsi: caller: cbail3
[2024/04/30 13:22:04:2821] I: [wsicli|1|WS/h1/default/localhost]: __lws_close_free_wsi: real just_kill_connection: sockfd 6
[2024/04/30 13:22:04:2821] I: [wsicli|1|WS/h1/default/localhost]: __lws_close_free_wsi: cce=0
[2024/04/30 13:22:04:2823] I: lws_tls_restrict_return: 1 -> 0
[2024/04/30 13:22:04:2823] I: rops_destroy_role_h1: ah det due to close

@qdztxc
Copy link
Author

qdztxc commented Apr 30, 2024

Is there a way to make above examples work? I plan to do test with and without SSL.

@lws-team
Copy link
Member

There seems to be a problem with tls on your platform? What is the platform + tls library?

What happens with eg, lws-minimal-http-client?

@qdztxc
Copy link
Author

qdztxc commented May 24, 2024

this seems caused by http proxy setting
export http_proxy = http://127.0.0.1:6721
actually the lws client and server deosn't require the proxy to connect.
Is there a way to specify to use or not user http_proxy in lws client?

@lws-team
Copy link
Member

Just don't explicitly tell it to use the proxy, eg unset http_proxy myapp ...

@qdztxc
Copy link
Author

qdztxc commented May 24, 2024

Is there a way to set whether to use proxy in lws code?
I'd like to implement program as 'try connect with proxy' -> fail -> 'try connect without proxy'

@lws-team
Copy link
Member

Under some other conditions that could be super bad, eg, if the proxy is supposed to conceal the connection from a monitored normal path, we would go ahead and blab about it anyway. The best way is just not explicitly tell it to use the proxy via the environment when that isn't what you want.

You can set the proxy in the context creation struct. So you if you want that flow, you can take a copy of the env proxy, unset it, and choose at context creation time whether to apply it or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants