简体   繁体   中英

Sockets not connecting in Java 7 Eclipse specific

Trying to run this test program: test socket connection with Java to connect to mail.iinet.net.au

Running on Windows 7 64bit

Initially everything works on Eclipse Indigo 64bit using jre1.6_27 I upgraded to jre1.7_17 and set eclipse to build the project using jre1.7. If I export the jar and run it from the command line everything works fine. However, running the same jar through eclipse, I get the following error:

Attempting: mail.iinet.net.au port: 25 ....
Failure:    mail.iinet.net.au/203.0.178.192:25 message: SocketTimeoutException - connect timed out 

So I upgraded to Eclipse Juno 64bit and I'm getting the same problem. Running through command line works, but not through Eclipse.

Why is it that upgrading to jre1.7 and running the above code in either Eclipse Indigo/Juno results in a timeout - but exporting the jars and running from the commandline works fine.

Also, telnet to mail.iinet.net.au from windows commandline works.

I wouldn't be surprised if your Anti-Virus is blocking Java, we had a similar issue with Kaspersky blocking a call from CouchBase within Eclipse. Try disabling/turning off your anti-virus temporarily and try again to verify

The issue was java 7 defaults to using the IPv6 stack instead of IPv4. Fixed it using details from https://stackoverflow.com/a/11850724/458493

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM