1

How would you investigate the following issue?

On a specific server; any HTTP-Requests sent to a Java Server running on localhost fails with "Connection refused". (See the Java code here)

In the Java Server-Application no sign of any problems is visible. The port seems to be listening, but when I try to send a HTTP request with cURL to the Java HTTP-Server application; cURL logs "Connection refused." (I use curl in mingw on the Windows 10 system)

The started Java Server application:

C:\test>java LogTCP_S 8000

Listening on port:8000, type Crtl-C to finish

The curl command [NOK]:

$ curl localhost:8000
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0

 curl: (7) Failed to connect to localhost port 8000: Connection refused

The same Java code works as expected on my Workstation.

I have also tried a different Java Application. I got the same result using the code from the following answer from StackOverflow: simple HTTP server in Java using only Java SE API

The issue happens on a Windows 10 System. There are several anomaly-detection tools and firewall applications and we are having a hard time to identify the source of the problem.

Hint: netstat -a won't list the port 8000. But it should be actually shown as LISTENING.

Hint: When starting a server in PowerShell (as described here), the communication works as expected. The port of the PowerShell Server will be listed in the netstat -a output and the requests return HTTP 200 and the expected content.

Could you please give me a hint, how to debug, investigate or resolve this issue? What tools could be helpful, when investigating such issues?

Any help would be greatly appreciated.

Thank you very much.

Java Version:

C:\>java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

Output of the PowerShell Server:

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.


PS C:\Temp\_test\PowerShell> .\server.ps1
[PowerShell] Listening at http://localhost:8000/... (port 8000)

> http://localhost:8000/ola
< 200

curl output, when the PowerShell is running [OK]:

$ curl localhost:8000/ola
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    38  100    38    0     0    612      0 --:--:-- --:--:-- --:--:--   612

<html><body>Hello world!</body></html>
  • 1
    Do you get any error/warning/other logs from the java server? If netstat -a does not show port 8000, then you should focus on that. Why does it seem that the java server started, but did not bind to the port? – Tommiie Oct 19 '18 at 8:11
  • No. I don't see any exception being thrown by the Java-Server-Application or anything being logged to the console. Everything seems to be fine in the Java-Application, but as you have described it, the binding seems to be not happening on this problematic system. Do you have any ideas how I could create some useful traces/logs in order to support the further Investigation of the issue? – Attila Oct 19 '18 at 8:39
0

After executing the following steps; the issue was not reproducible anymore:

  • Stopped the Symantec Anti-Virus service
  • Re-installed Java JDK 8 u 171

After restarting the Symantec Anti-Virus Service; the issue is still not reproducible and the problem seems to be solved.

Now the ports, that are opened by Java applications, appear in the Output of "netstat -a" and they also respond as expected. The HTTP-requests sent to Java application are now arriving in the JVM and the responses can be sent.

It is still not completely clear, what caused the issue.

  • Do you have any clues what could have caused the issue? Is it possible that the Antivirus-tool blocked a specific excecutable binary, which was replaced after re-installing the JDK and this solved the issue? – Attila Oct 23 '18 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.