Skip to content

Conversation

@yassineBT
Copy link

LWS fails to queue connection when mixing IP and Hostname, the issue occurs due to how lws_client_connect_info fields (address, origin, and host) are configured. Specifically, when the fields are set as follows:

address = IP
origin = hostname
host = hostname

Example:

address = 81.71.211.11
origin = ybt.test.com
host = ybt.test.com

Using an IP address instead of a hostname prevents LWS from performing DNS resolution, as the resolution is handled externally. However, with this configuration, LWS incorrectly compares 81.71.211.11 with ybt.test.com for the second session, treating it as a new session instead of an existing one.

Fix:
Ensure consistent comparison by matching IP to IP or host to host. This fix updates the logic to compare IP addresses directly, preventing LWS from incorrectly creating a new session instead of properly queuing it.

@lws-team
Copy link
Member

lws-team commented Mar 2, 2025

Thanks... I don't really want to change the behaviour for the normal case that the address is a DNS name, as this patch seems to do.

For the vast majority of people, they are using TLS and it is based on confirming that the cert that is served and signed by the CA, matches the DNS name.

I understand the behaviour at the moment when using pipelining with an IP address is wrong, but it sounds like the patch should work around that for the explicit IP case only, and leave the normal case as it is.

@yassineBT
Copy link
Author

Thank you, Sir, for the library and your support.

I might be mistaken or perhaps I misunderstood your comment—please bear with me if I’m lacking knowledge here—but I don’t quite see how it changes the behavior. I’d be interested to know if this patch could have any impact.

The patch's goal is simply to compare two elements of the same type. When I mixed IP and hostname in my application, I noticed that a new session was triggered each time I attempted to connect. This was because !strcmp(adsin, w->cli_hostname_copy) compares an IP (adsin) with a hostname (w->cli_hostname_copy).

I combined IP and hostname for the following reasons:

  • To leverage the TLS verification on the hostname implemented in the library.
  • To prevent LWS from performing DNS resolution, as my application handles DNS resolution and includes an IP affinity mechanism that controls when to stick to an IP and when to switch to another.

@lws-team lws-team force-pushed the main branch 5 times, most recently from a0c73c1 to 7c9d4bc Compare September 9, 2025 14:28
@lws-team lws-team force-pushed the main branch 12 times, most recently from a800d4a to 7f2f518 Compare September 18, 2025 08:03
@lws-team lws-team force-pushed the main branch 3 times, most recently from baf4897 to 0c7fa23 Compare October 1, 2025 14:55
@lws-team lws-team force-pushed the main branch 3 times, most recently from 2b74af4 to 5f77374 Compare October 12, 2025 10:02
@lws-team lws-team force-pushed the main branch 5 times, most recently from a677221 to 0c67054 Compare October 24, 2025 16:36
@lws-team lws-team force-pushed the main branch 2 times, most recently from f5fa440 to 278c671 Compare November 6, 2025 08:28
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

Successfully merging this pull request may close these issues.

2 participants