Open antony opened 6 years ago
Noticing the same problem. This is pretty strange.
Host (expected behavior)
$ uname -a
Linux host 4.9.0-7-amd64 #1 SMP Debian 4.9.110-3+deb9u2 (2018-08-13) x86_64 GNU/Linux
$ curl --version
curl 7.52.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.2l zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
$ curl --retry 10 --retry-connrefused localhost:123
Warning: Transient problem: connection refused Will retry in 1 seconds. 10
Warning: retries left.
Warning: Transient problem: connection refused Will retry in 2 seconds. 9
Warning: retries left.
Warning: Transient problem: connection refused Will retry in 4 seconds. 8
Warning: retries left.
^C
$
Inside container (erroneous behavior)
$ docker exec -it container sh
...
$ uname -a
Linux container 4.9.0-7-amd64 #1 SMP Debian 4.9.110-3+deb9u2 (2018-08-13) x86_64 GNU/Linux
$ curl --version
curl 7.52.1 (x86_64-pc-linux-gnu) libcurl/7.52.1 OpenSSL/1.0.2l zlib/1.2.8 libidn2/0.16 libpsl/0.17.0 (+libidn2/0.16) libssh2/1.7.0 nghttp2/1.18.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
$ curl --retry 10 --retry-connrefused localhost:123
curl: (7) Failed to connect to localhost port 123: Connection refused
$
These look possibly related:
Same problem in Docker:
Host (Mac)
curl --version
curl 7.54.0 (x86_64-apple-darwin18.0) libcurl/7.54.0 LibreSSL/2.6.4 zlib/1.2.11 nghttp2/1.24.1
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy
$ curl -H "Content-Type:application/json" --retry 12 --retry-connrefused --retry-delay 5 --max-time 60 -XPOST http://localhost:9002/
Warning: Transient problem: connection refused Will retry in 5 seconds. 12
Warning: retries left.
Warning: Transient problem: connection refused Will retry in 5 seconds. 11
Warning: retries left.
Docker
curl --version
curl 7.62.0 (x86_64-pc-linux-gnu) libcurl/7.62.0 OpenSSL/1.0.1t zlib/1.2.8
Release-Date: 2018-10-31
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy
root@c246d4fbf3b1:/plugins-scripts/logs#
root@c246d4fbf3b1:/plugins-scripts/logs# curl -H "Content-Type:application/json" --retry 12 --retry-connrefused --retry-delay 5 --max-time 60 -XPOST http://localhost:9002/
curl: (7) Failed to connect to localhost port 9002: Connection refused
I think you can solve it by forcing curl to use IPv4 via the -4
flag .
Here are some tests:
docker run --rm -it appropriate/curl --retry 4 --retry-connrefused --retry-delay 3 http://localhost:8888
curl: (7) Failed to connect to localhost port 8888: Connection refused
docker run --rm -it appropriate/curl -4 --retry 4 --retry-connrefused --retry-delay 3 http://localhost:8888
Warning: Transient problem: connection refused Will retry in 3 seconds. 4
Warning: retries left.
Warning: Transient problem: connection refused Will retry in 3 seconds. 3
Warning: retries left.
Warning: Transient problem: connection refused Will retry in 3 seconds. 2
Warning: retries left.
Warning: Transient problem: connection refused Will retry in 3 seconds. 1
Warning: retries left.
curl: (7) Failed to connect to localhost port 8888: Connection refused
It appears without this flag, curl
tries to use both IPv4 and IPv6 and when it doesn't receive an IPv6 address the error code is not a connection retry:
strace curl --retry 4 --retry-connrefused --retry-delay 3 http://localhost:8888 2>&1 | grep connect
connect(3, {sa_family=AF_INET, sin_port=htons(8888), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation in progress)
connect(4, {sa_family=AF_INET6, sin6_port=htons(8888), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = -1 EADDRNOTAVAIL (Address not available)
connect(3, {sa_family=AF_INET6, sin6_port=htons(8888), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = -1 EADDRNOTAVAIL (Address not available)
Seems like the docker process exits, which is the opposite of what one might expect.