Skip to content

Localhost DNS lookup fails without network connection #524

Closed

Description

@MichelJansson

Hi! Thanks again for the lib!

I mostly use this library on windows to connect to a local server via "wss://localhost". This normally works fine, but when not connected to a network (network cable unplugged and not connected to wifi), IXWebsockets fails to connect to my server.

I tracked it down to failing DNS lookup of localhost. Digging into the code, I see getaddrinfo is configured not to do lookups when a with only a loopback address available (hint AI_ADDRCONFIG is set):

hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;

As a workaround I tested to remove that flag and my program started working as expected.

I'm not proficient in winsock etc, so I can't tell if there any specific reason for the flag to be set for the library or can it be removed or made configurable?

Thanks!

Activity

  1. bsergean commented on Sep 27, 2024

    @bsergean
    Collaborator

    Hey a quick workaround too is to try

    wss://127.0.0.1 instead of localhost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions