Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>>
 
Sheriff
Posts: 22778
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 22778
130
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic