Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMAPSYNC IO::Socket::IP configuration failed Connection refused #184

Open
conandrum opened this issue Jul 12, 2019 · 9 comments
Open

IMAPSYNC IO::Socket::IP configuration failed Connection refused #184

conandrum opened this issue Jul 12, 2019 · 9 comments
Assignees
Labels
Docker Installation Installation problems and dependencies Ubuntu Ubuntu issues

Comments

@conandrum
Copy link

Operating system Ubuntu Linux 18.04.2

I am facing a strange issue with IMAPSYNC when syncing emails from a remote host to the localhost.

First of all, telnet is not allowed by the firewall, but I can confirm that dovecot is listening on port 993.

netstat -nap | grep 993
tcp        0      0 0.0.0.0:993             0.0.0.0:*               LISTEN      873/dovecot
tcp6       0      0 :::993                  :::*                    LISTEN      873/dovecot

I can further confirm that I have mail auto-config and MS Outlook can connect remotely to the server and sync emails.
I can also confirm that issuing this command begins synchronization and successfully executes:

imapsync --dry --ssl1 --ssl2 --host1 remoteserver.com --user1 user@remoteserver.com --password1 'MASKED' --host2 localhost --user2 user@localserver.com --password2 'MASKED'

Debug level 4 output of above successful command:

Host2: connecting and login on host2 [localhost] port [993] with user [user@localserver.com]
DEBUG: .../IO/Socket/SSL.pm:2853: new ctx 93973258583824
DEBUG: .../IO/Socket/SSL.pm:692: socket not yet connected
DEBUG: .../IO/Socket/SSL.pm:694: socket connected
DEBUG: .../IO/Socket/SSL.pm:717: ssl handshake not started
DEBUG: .../IO/Socket/SSL.pm:750: using SNI with hostname localhost
DEBUG: .../IO/Socket/SSL.pm:806: set socket to non-blocking to enforce timeout=120
DEBUG: .../IO/Socket/SSL.pm:819: call Net::SSLeay::connect
DEBUG: .../IO/Socket/SSL.pm:822: done Net::SSLeay::connect -> -1
DEBUG: .../IO/Socket/SSL.pm:832: ssl handshake in progress
DEBUG: .../IO/Socket/SSL.pm:842: waiting for fd to become ready: SSL wants a read first
DEBUG: .../IO/Socket/SSL.pm:862: socket ready, retrying connect
DEBUG: .../IO/Socket/SSL.pm:819: call Net::SSLeay::connect
DEBUG: .../IO/Socket/SSL.pm:822: done Net::SSLeay::connect -> -1
DEBUG: .../IO/Socket/SSL.pm:832: ssl handshake in progress
DEBUG: .../IO/Socket/SSL.pm:842: waiting for fd to become ready: SSL wants a read first
DEBUG: .../IO/Socket/SSL.pm:862: socket ready, retrying connect
DEBUG: .../IO/Socket/SSL.pm:819: call Net::SSLeay::connect
DEBUG: .../IO/Socket/SSL.pm:822: done Net::SSLeay::connect -> 1
DEBUG: .../IO/Socket/SSL.pm:877: ssl handshake done
Host2 IP address: 127.0.0.1
Host2 banner: * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot (Ubuntu) ready.
Host2 capability before authentication: IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN AUTH
Host2: localhost says it has CAPABILITY for AUTHENTICATE LOGIN
Host2: success login on [localhost] with user [user@localserver.com] auth [LOGIN]

PROBLEM:
When I use the public IP address of the local server, or the name. These fail:

imapsync --dry --ssl1 --ssl2 --host1 remoteserver.com --user1 user@remoteserver.com --password1 'MASKED' --host2 xxx.xxx.xxx.xxx --user2 user@localserver.com --password2 'MASKED'

imapsync --dry --ssl1 --ssl2 --host1 remoteserver.com --user1 user@remoteserver.com --password1 'MASKED' --host2 mail.localserver.com --user2 user@localserver.com --password2 'MASKED'

Debug level 4 error:

Host2: connecting and login on host2 [mail.localserver.com] port [993] with user [user@localserver.com]
DEBUG: .../IO/Socket/SSL.pm:2853: new ctx 93834940862224
DEBUG: .../IO/Socket/SSL.pm:692: socket not yet connected
DEBUG: ...5.26/IO/Socket.pm:48: local error: IO::Socket::IP configuration failed
DEBUG: .../IO/Socket/SSL.pm:2875: free ctx 93834940862224 open=93834970518272 93834940862224
DEBUG: .../IO/Socket/SSL.pm:2886: OK free ctx 93834940862224
Host2 failure: can not open imap connection on host2 [mail.localserver.com] with user [user@localserver.com]: Unable to connect to mail.localserver.com: IO::Socket::IP configuration failed Connection refused
Exiting with return value 10 (EXIT_CONNECTION_FAILURE)

Any ideas?

@gilleslamiral gilleslamiral self-assigned this Jul 14, 2019
@gilleslamiral
Copy link
Member

Do you perform the run from the same host?
Is it an IPv6 address when using name? Test with ::1,
What gives:

./imapsync --host2 ::1

@conandrum
Copy link
Author

conandrum commented Jul 15, 2019

Hi G,
host1 is my remote host. I run all the above commands on host2. IPv6 is disabled on host2.
when I use ::1 for host2 it is OK.

Host2 IP address: ::1
Host2 banner: * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] Dovecot (Ubuntu) ready.
Host2 capability before authentication: IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN AUTH
Host2: ::1 says it has CAPABILITY for AUTHENTICATE LOGIN
Host2: success login on [::1] with user [user@localserver.com] auth [LOGIN]
Host1: state Authenticated
Host2: state Authenticated

@conandrum
Copy link
Author

I do not know what was causing this problem. I reinstalled everything on the VPS and tried again just now and it is OK.
What I noticed last time, was that functionality broke after midnight, so it could be some update that got installed on the server.
If it happens again I will revisit this thread.
Thanks

@gilleslamiral
Copy link
Member

Fixed. Closing

@gilleslamiral gilleslamiral added Installation Installation problems and dependencies Ubuntu Ubuntu issues labels Aug 30, 2019
@jeee
Copy link

jeee commented Mar 23, 2021

I get a similar error:
Host1: connecting and login on host1 [] port [993] with user [] DEBUG: ...5.28/IO/Socket.pm:47: local error: IO::Socket::IP configuration failed Host1 failure: can not open imap connection on host1 [] with user []: Unable to connect to : IO::Socket::IP configuration failed Connection timed out Exiting with return value 10 (EXIT_CONNECTION_FAILURE) 1/50 nb_errors/max_errors

on a clear install running on the destination host. Running it on another host (which I used as a test server with same config) with the IPs of the one that fails seems to work fine. Also connecting on the command line to the 993 works fine.

@gilleslamiral
Copy link
Member

Can you give the full log?

@gilleslamiral gilleslamiral reopened this Mar 23, 2021
@jeee
Copy link

jeee commented Mar 23, 2021

Don't think there is much more of interest:

Changing current directory to /var/tmp/
get options: [1][16]
numopt:16
Here is imapsync 1.983 on host 015f92ef9a7b, a linux system with 0.3/3.8 free GiB of RAM
with Perl 5.28.1 and Mail::IMAPClient 3.42
Transfer started at Tue Mar 23 19:15:08 2021
PID is 1 my PPID is 0
System load: 0.00 0.01 0.03 2/328
Load is 0.00 0.01 0.03 2/328 on 2 cores
Current directory is /var/tmp
Real user id is nobody (uid 65534)
Effective user id is nobody (euid 65534)
check_last_release: [timeout]
$RCSfile: imapsync,v $ $Revision: 1.983 $ $Date: 2020/03/19 02:08:12 $ 
Command line used, run by /usr/bin/perl:
/usr/bin/imapsync --host1 11.11.11.11 --ssl1 --user1 user@domain.com*user --password1 MASKED --host2 22.22.22.22 --user2 user@domain.com*user --password2 MASKED --ssl2 --dry --debug
Temp directory is /tmp ( to change it use --tmpdir dirpath )
Under docker context so installing only signals to exit
kill -INT 1 # special behavior: call to sub catch_exit
kill -QUIT 1 # special behavior: call to sub catch_exit
kill -TERM 1 # special behavior: call to sub catch_exit
No variable pid_filename
PID file is unset ( to set it, use --pidfile filepath ; to avoid it use --pidfile "" )
Modules version list:
Authen::NTLM         1.09
CGI                  4.40
Compress::Zlib       2.074
Crypt::OpenSSL::RSA  0.31
Data::Uniqid         0.12
Digest::HMAC_MD5     1.01
Digest::HMAC_SHA1    1.03
Digest::MD5          2.55
Encode               2.97
Encode::IMAPUTF7     1.05
File::Copy::Recursive 0.44
File::Spec           3.74
Getopt::Long         2.5
HTML::Entities       3.69
IO::Socket           1.39
IO::Socket::INET     1.39
IO::Socket::INET6    2.72
IO::Socket::IP       0.39
IO::Socket::SSL      2.060
IO::Tee              0.65
JSON                 4.02
JSON::WebToken       0.10
LWP                  6.36
MIME::Base64         3.15
Mail::IMAPClient     3.42
Net::Ping            2.62
Net::SSLeay          1.85
Term::ReadKey        2.38
Test::MockObject     1.20180705
Time::HiRes          1.9759
URI::Escape          3.31
Unicode::String      2.10
( use --no-modulesversion to turn off printing this Perl modules list )
IMAPClient 3.42
Info: will resync flags for already transferred messages. Use --noresyncflags to not resync flags.
sslcheck
SSL debug mode level is --debugssl 1 (can be set from 0 meaning no debug to 4 meaning max debug)
Host1: SSL default mode is like --sslargs1 "SSL_verify_mode=0", meaning for host1 SSL_VERIFY_NONE, ie, do not check the certificate server.
Host1: Use --sslargs1 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the certificate server of host1
Host2: SSL default mode is like --sslargs2 "SSL_verify_mode=0", meaning for host2 SSL_VERIFY_NONE, ie, do not check the certificate server.
Host2: Use --sslargs2 SSL_verify_mode=1 to have SSL_VERIFY_PEER, ie, check the certificate server of host2
Info: turned ON syncinternaldates, will set the internal dates (arrival dates) on host2 same as host1.
Host1: will try to use LOGIN authentication on host1
Host2: will try to use LOGIN authentication on host2
Host1: imap connection timeout is 120 seconds
Host2: imap connection timeout is 120 seconds
Host1: IMAP server [11.11.11.11] port [993] user [user@domain.com*user]
Host2: IMAP server [22.22.22.22] port [993] user [user@domain.com*user]
Host1: connecting and login on host1 [11.11.11.11] port [993] with user [user@domain.com*user]
DEBUG: ...5.28/IO/Socket.pm:47: local error: IO::Socket::IP configuration failed
Host1 failure: can not open imap connection on host1 [11.11.11.11] with user [user@domain.com*user]: Unable to connect to 11.11.11.11: IO::Socket::IP configuration failed Connection timed out
Exiting with return value 10 (EXIT_CONNECTION_FAILURE) 1/50 nb_errors/max_errors```

@gilleslamiral
Copy link
Member

Thanks!

The context is docker.

What gives:

docker run gilleslamiral/imapsync imapsync --testslive

There is no nmap nor telnet nor openssl in the imapsync Docker image, I should add this trouble-shouting tool in it.

What gives:

docker run gilleslamiral/imapsync ping -c2  11.11.11.11

But there is wget inside the imapsync docker image, great!

What gives:

docker run gilleslamiral/imapsync wget -O- https://11.11.11.11:993

and also, by comparison:

docker run gilleslamiral/imapsync wget -O- https://test1.lamiral.info:993

@gilleslamiral
Copy link
Member

gilleslamiral commented Mar 27, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docker Installation Installation problems and dependencies Ubuntu Ubuntu issues
Projects
None yet
Development

No branches or pull requests

3 participants