Getting "Socket error: nodename nor servname provided, or not known" making API calls with http_open/3

I’m getting “Socket error: nodename nor servname provided, or not known” using http_open/3 to make API calls.

I only seem to getting them for longer-running applications where I’m making 1k-2k calls in quick succession but not in cases where I’m only making 10-20 calls.

Research on the error shows it’s likely a DNS error but some initial troubleshooting such as updating my /etc/host file, clearing my DNS cache, and using a different DNS provider are proving fruitless and what I would like to do is exclude an http_open/3 bug as the culprit.

Has anyone run into this error before?

I would install unbound as the system DNS provider. I always use it, personally, because DNS is important and worth this small setup effort to be cached.

If not using unbound - did you set multiple DNS providers (e.g. 3 nameserver lines), as per standard practice?

Doesn’t ring a bell. Does smell like a low level issue though. Are you sure you close the connections? I’d typically try some low level tools for tracing the socket calls, depending on the OS.

I’d consider using Keep-alive connections though.

@brebs I was initially using the default DNS settings on macos which were my ipv4 default gateway and two ipv6 addresses which I’m not sure what those are. Then I changed it to the two google DNS servers 8.8.8.8 and 8.8.4.4 and my gateway.

@jan I am not currently setting a connection type and the doc says it defaults to Close. Would Keep-Alive help even if all I’m doing is pulling jsons? Would this be correct?

 http_open(Endpoint,Response,[
        authorization(bearer(Key)),
        connection('Keep-alive')
    ])

It has nothing to do with the request. It simply uses the HTTP 1.1 feature to run multiple requests on the same connection. Note that, if I recall correctly, it still disconnects if there are HTTP errors.