aspose file tools*
The moose likes Java in General and the fly likes Socket communiction works on XP but not on Vista Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Socket communiction works on XP but not on Vista" Watch "Socket communiction works on XP but not on Vista" New topic
Author

Socket communiction works on XP but not on Vista

Allan Sorenson
Greenhorn

Joined: Aug 21, 2008
Posts: 10
Situation summary:
Running two java applications on the same machine.
App A is launched and creates a ServerSocket on port 4445.
App B is launched after App A. It creates a ServerSocket on port 4446 and then sends a message to port 4445 (send config).
App A receives message on port 4445 and sends message (config) to port 4446.
App B receives message on port 4446.

This worked fine on all flavors of XP (and I believe it was tested on Windows NT, 2000 and 2003, too).
When tried on Vista, both Apps are unable to send messages; java.net.ConnectException: Connection refused: connect.
Neither app has a problem with serversocket creation or accept() (at least no error is reported).

I turned off the firewall with no change.

I am new to Vista and need some guidance as to what to try next.

Abbreviated details:
App B


App A code is the same except for portNum.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

Welcome to the Java Ranch
I just whipped up a simple test app on Vista that just bound to a port and another app which connected to that port. I got a firewall popup that indicated that my "server" was blocked and it allowed me to make an exception. After adding the exception, the program worked just like on XP.
Can you give us an small sample app (or two, in this case) which exhibits this behavior?
[ August 21, 2008: Message edited by: Joe Ess ]

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5830
    
    7

You could use the TCPView app from sysinternals to determine if the ports are opened (and who has them open).

Also, I have found that turning off the firewall is sometimes not that helpful. I have had to uninstall the firewall and reboot to get certain things to run (this was on XP and Vista).


JBoss In Action
Sam Lalani
Greenhorn

Joined: Aug 22, 2008
Posts: 6
I have a similar problem except I'm connecting to an external server. My program simply does:

Socket socket = new Socket (host, port);

and it works for a few hundred customers except for two who both happen to have Vista Home Premium. We have other customers for whom it does work on Vista Home Premium.

On the computers where it does not work, I have had them use the TELNET program to see if there is a problem with some security program blocking the host or port. However, I am able to connect via TELNET to the same host and port but the Java program tries to connect and a couple of minutes later returns with an Exception. I know that the TELNET connection works because I watch the server and it does receive what I ask them to type.

Does Vista have some kind of a security issue where it may be blocking access to ports on certain programs?
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5830
    
    7

it may be blocking access to ports on certain programs?


If I get this correctly, your customer runs a Java app that connects to your server. If that is the case, the answer to your question is "Yes." Most firewall apps that block outbound requests do it based on the full path name of the application's .exe file that is making the outbound request.

One of the things I have noticed in firewall configuration is that many firewalls offer "automatic" or "manual" configuration modes. In "manual" mode, it asks you about every outbound connection and if you want to accept it. In "automatic" configuration mode, it guesses. In many cases it guesses wrong so I always set up my firewall to use "manual" mode.

But even in manual mode, here is what could happen. The user runs some Java app, a pop appears asking for network access, and the user clicks on "no". The app runs just fine. Later the user runs your Java app and finds she cannot connect. The reason is that the exact same java.exe file is being used for both Java apps - the firewall cannot distinguish between Java apps.

One thing you can try is have them verify that their firewall is in "manual" config mode, then install a new JDK, and run the app with the java.exe from that JDK. The firewall should then ask for permission again. Alternately, they could clean up the program configuration in the firewall - most firewalls will tell you how each .exe file is configured (allow vs. disallow), and you can often remove entries from this table.
Sam Lalani
Greenhorn

Joined: Aug 22, 2008
Posts: 6
First, thank you for the response.

A correction: The first customer to have the problem has Vista Basic, and the second customer has Vista Home Premium.

The first customer has an E-machine, and to attempt to fix the problem, we reinstalled his OS, did NOT install his anti-virus, and turned off the firewall. The problem still existed where TELNET connected to the server but the Java program did not. So we thought it may be his router, so we connected our laptop to his router and the Java program ran fine on the laptop.

This is a very strange problem. And now that there is a second customer with a similar issue, we're thinking there's something we're missing that is in the Vista OS that's pre-packaged with these computers.

Any thoughts on this problem will be appreciated.

Thanks.
Allan Sorenson
Greenhorn

Joined: Aug 21, 2008
Posts: 10
It turns out that the problem was HOW App B was being launched. App B was launched by App A via an InstallAnywhere LaunchAnywhere created with IA 5.5. Generally, it looks like an IA 5.5 LaunchAnywhere and Vista do not play nice.

Thanks for your ideas and suggestions!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Socket communiction works on XP but not on Vista