• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Java socket unexpectedly gets closed (RRDTOOL invokation)

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I installed rrdtool in a Centos 5.5 server , the rrdtool is accessed by a Java program through a socket:

SocketAddress sa = new InetSocketAddress(config.getRrdServiceHost(), config.getRrdServicePort());
Socket socket = new Socket();
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
String command = StringUtils.join(new String[]{
"create", rrdFileRel,
"--start", Long.toString(timestamp - config.getStartTimeOffset()),
"--step", "300",
"DS:ds0:" + type + ":900:U:U",
"RRA:AVERAGE:0.5:1:8640",

And the reply is read like this:
out.println(command);
out.flush();
response = in.readLine();

The snippet above works most of the time, but for some reason after some dozens of graphics are generated the RRDTOOL closes unexpectedly the sockets it get invoked through, I already took a TCP-dump and it can observed hot the RRDTOOL is invoked successfully many times but unexpectedly closes the connection:

create file:mycounter13180/stats.mycom.rrd --start 1286986228 --step 300 DS:ds0:ABSOLUTE:900:U:U ...
Reply:
OK u:0.00 s:0.01 r:0.01

But the last invocation fails:
create file:anothercounter13180/stats.mycom.rrd --start 1286986228 --step 300 DS:ds0:ABSOLUTE:900:U:U ...
Reply:
none

Thus, the socket suddenly gets closed.
ERROR 2010-10-13 12:10:39,126 [ ] [stat-runner-1] com.colibria.imps.statistics.service.StatisticsService.run - Failed to read stat from imps nodes
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at java.io.BufferedReader.fill(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)


If there's a way to prevent this error from my Java program please let me know.

Thanks in advanced.
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic