IXWebSocket icon indicating copy to clipboard operation
IXWebSocket copied to clipboard

Localhost DNS lookup fails without network connection

Open MichelJansson opened this issue 1 year ago • 1 comments

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): https://github.com/machinezone/IXWebSocket/blob/9884c325dd0fa64b2b885b332e98118f60313208/ixwebsocket/IXDNSLookup.cpp#L64

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!

MichelJansson avatar Aug 26 '24 15:08 MichelJansson

Hey a quick workaround too is to try

wss://127.0.0.1 instead of localhost

bsergean avatar Sep 27 '24 22:09 bsergean