aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes java.net.ConnectException: Connection refused: connect during regression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.net.ConnectException: Connection refused: connect during regression" Watch "java.net.ConnectException: Connection refused: connect during regression" New topic
Author

java.net.ConnectException: Connection refused: connect during regression

Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Hi Fellas,

My application has a number of HTTP web services. While writing a regression test I am getting "java.net.ConnectException: Connection refused: connect" exception.
Though I have verified that the service never goes down even when these errors come. The test class is attached for reference.
Please suggest what is not working out here.



Thanks in advance.


<<updated code as per Rob's suggestions>>
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

The first array element uses port 2001, the others use 7001. Maybe that's the problem?

Also, your time measurement only measures how long it takes to submit all these requests. The requests themselves are executed in different threads. Store the results of the calls to es.submit() into a List<Future<?>>, then after the submitting of all requests loop over this List and call get() on each element.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Thanks Rob. The port probably got incorrect while changing the URL's to dummy
Thanks for the time evaluation tip.
Though the real problem that's happening is that, when i run the program a large number of requests fail with the java.net.ConnectException: Connection refused: connect

Thanks,
Anubhav
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

Sample console output for the program is as below, so the service is becoing unavailable for intermittent requests.



Thanks,
Anubhav
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

I suggest you change the run method slightly to also print out which URLs are giving problems:
Perhaps you'll notice a pattern.
Anubhav Anand
Ranch Hand

Joined: May 18, 2007
Posts: 341

I included the url in the error, but couldn't see a pattern, as the url calls are randomized, so randomly they fail.
Though i found this link, and when i ran with requests less than 3900, the program worked
correctly for most times in windows.

Thanks,
Anubhav
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.net.ConnectException: Connection refused: connect during regression