Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anubhav Anand
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sample console output for the program is as below, so the service is becoing unavailable for intermittent requests.



Thanks,
Anubhav
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic