0

Since the last update to Avast Antivirus, I can no longer connect to POP3 e-mail servers using java.net.Socket. Mozilla Thunderbird works fine, and I can also connect using PuTTY (raw, port 110).

Connecting to other ports than 110 works fine. When the following code is run:

try
{
    System.out.println("Connecting to www.google.com:80");
    java.net.Socket socket1 = new Socket("www.google.com", 80);
    System.out.println("Connected");
    socket1.close();

    System.out.println("Connecting to pop01.binero.se:110");
    java.net.Socket socket2 = new Socket("pop01.binero.se", 110);
    System.out.println("Connected");
    socket2.close();
}
catch(Exception ex)
{
    ex.printStackTrace();
}

it outputs:

Connecting to www.google.com:80
Connected
Connecting to pop01.binero.se:110
java.net.ConnectException: Connection refused: connect
        at java.base/java.net.PlainSocketImpl.connect0(Native Method)
        at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:101)
        at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
        at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
        at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
        at java.base/java.net.Socket.connect(Socket.java:591)
        at java.base/java.net.Socket.connect(Socket.java:540)
        at java.base/java.net.Socket.<init>(Socket.java:436)
        at java.base/java.net.Socket.<init>(Socket.java:213)
        at SocketTest.main(SocketTest.java:15)

If I disable Avast MailShield for incoming mail, I can connect using the above code. As far as I know, MailShield intercepts the TCP connection from e-mail client and scans any e-mail attachments. If it finds a virus, it adds an alert text to the e-mail subject.

What I don't understand is how it intercepts the TCP connection, how it distinguishes between my program, Thunderbird or PuTTY and why it blocks only my program.

I would like to keep MailShield activated for Thunderbird, and either disable it for my own program or make Avast recognize my program as a valid e-mail client and let it through.

Anlo
  • 3,228
  • 4
  • 26
  • 33

1 Answers1

0

Usually window update will update JDK path. U need reconfigs JDK path How to set java_home on Windows 7?

Tan Bui
  • 137
  • 3
  • 11
  • If the JDK path was wrong the program would not start at all, right? I've had that problem before, when Windows says it can't find the javaw.exe program. Now the program starts up fine, but can't connect to the mail servers. – Anlo Apr 01 '19 at 07:24