Open shiftee opened 12 months ago
Okay it looks like the issue is in net__try_connect_tcp()
mosquitto_connect() mosquitto_connect_bind() mosquitto_connect_bind_v5() mosquitto__reconnect() net__socket_connect() net__try_connect() net__try_connect_tcp()
getaddrinfo() is returning the following addresses for test.mosquitto.org
0.0.0.0 is passed to connect() first and takes up all the time.
On my x86_64 desktop the same addresses are returned but in the opposite order, so the problem is not seen.
so what's giving you the 0.0.0.0 response? that's obviously garbage... (andentirely within yourown resolver setup...)
Both addresses are appearing on Mobian Bookworm and Ubuntu 23.04 at my home. Both also appear on a SLES15 SP4 server at my workplace which has no relation to my DNS.
It looks to me like getaddrinfo() is including 0.0.0.0 when it shouldn't.
The below zipped patch prints all returned addresses, give it a try if you have time: 0001-Print-the-ip-addresses-from-getaddrinfo.zip
Okay, the 0.0.0.0 values are what you get if you pass IPV6 addresses to inet_ntoa().
Using inet_ntop() I get the following: ::2001:41d0:1:925e:0:0 91.121.93.94
I cannot ping that IPv6 address from home, work or this site: https://www.ipvoid.com/ipv6-ping-test
Can you look into that please?
sounds like your system believes it can do v6, but it actually can't? That site works for me to ping "test.mosquitto.org"
PING test.mosquitto.org(2001:41d0:1:925e::1 (2001:41d0:1:925e::1)) 56 data bytes
64 bytes from 2001:41d0:1:925e::1 (2001:41d0:1:925e::1): icmp_seq=1 ttl=54 time=73.6 ms
64 bytes from 2001:41d0:1:925e::1 (2001:41d0:1:925e::1): icmp_seq=2 ttl=54 time=73.6 ms
64 bytes from 2001:41d0:1:925e::1 (2001:41d0:1:925e::1): icmp_seq=3 ttl=54 time=72.6 ms
--- test.mosquitto.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 72.551/73.251/73.619/0.495 ms
Note that your resolver is giving you this invalid " ::2001:41d0:1:925e:0:0" not the actual AAAA response tooo...
;; ANSWER SECTION:
test.mosquitto.org. 3583 IN AAAA 2001:41d0:1:925e::1
It looks like the returned addresses are correct and were simply being formatted incorrectly. The interfaces are a bit tricky and I am not familiar with them, sorry. But indeed IPv6 is not working from my phone. I guess I need to fix it, or prevent IPV6 addresses from being returned from DNS. Sorry for the trouble and thanks for the help.
If I had known an IPv6 address was being used then this ticket would probably not have been opened. What do you think of adding something like the commit below? logprintf() requires the mosq param though. Would it be acceptable to pass mosq down from netsocket_connect() to net__try_connect_tcp()?
https://github.com/shiftee/mosquitto/commit/eb2bdcf38caeca93eb8c5ebea4d3683f7ddf2fb4
Hi,
I am working on a PinePhone app which uses libmosquitto.
It works fine on my x86_64 development machine. Running on the phone (mobian/bookworm) it waits in mosquitto_connect() for ~129s before opening the TCP connection.
This issue also seems to be present in the latest mosquitto git:
It works with a 3 minute keepalive: