Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java socket unexpectedly gets closed (RRDTOOL invokation)

Robert Garrido
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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",

And the reply is read like this:
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 ...
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 ...

Thus, the socket suddenly gets closed.
ERROR 2010-10-13 12:10:39,126 [ ] [stat-runner-1] - Failed to read stat from imps nodes Connection reset
at Source)
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
at Source)
at Source)
at Source)
at Source)
at Source)

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

Thanks in advanced.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic