Remote appender has "Connection reset by peer" error

52 views
Skip to first unread message

黄颖志

unread,
Apr 13, 2015, 3:08:02 AM4/13/15
to java-ch...@googlegroups.com
I am a new Chronicle user, I have two JAVA main classes, one is chronicle source, and other is remote appender.

Source:
public class MQServer {
public static void main(String[] args) throws IOException, InterruptedException {
String basePath = System.getProperty("java.io.tmpdir") + "/getting-started";
Chronicle source = ChronicleQueueBuilder.indexed(basePath).source().bindAddress("localhost", 1234).build();
source.clear();
Thread.currentThread().sleep(1000 * 60 * 60);
}

}

Remote Appender:
public class RemoteAppender {
public static void main(String[] args) throws IOException {
Chronicle chronicle = ChronicleQueueBuilder
.remoteAppender()
.connectAddress("localhost", 1234)
.build();
ExcerptAppender appender = chronicle.createAppender();
appender.startExcerpt(100);
appender.writeObject("Message");
appender.finish();
}
}

I run MQServer there is no error, and when RemoteAppender starts, I get error:
        [main] INFO sink-initiator[localhost/127.0.0.1:1234] - Connected to localhost/127.0.0.1:1234 from /127.0.0.1:41583
         Exception in thread "main" java.lang.IllegalStateException: java.io.IOException: Connection reset by peer

Is there something wrong with my code, or the way i use Chronicle is wrong.

Peter Lawrey

unread,
Apr 13, 2015, 3:18:05 AM4/13/15
to java-ch...@googlegroups.com

The remote appender exits without closing the connection gracefully. Can you use the try with resource on the chronicle?

--
You received this message because you are subscribed to the Google Groups "Chronicle" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-chronicl...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

黄颖志

unread,
Apr 13, 2015, 5:47:30 AM4/13/15
to java-ch...@googlegroups.com
I am sorry, i am chinese, my english is bad, i cannot catch your mean "use the try with resource on the chronicle";
 If  i use remote appender , i will get error, if i modified like follewed, there is no error.

public class MQServer {
public static void main(String[] args) throws IOException, InterruptedException {
String basePath = System.getProperty("java.io.tmpdir") + "/getting-started";
Chronicle source = ChronicleQueueBuilder.indexed(basePath).source().bindAddress("localhost", 1234).build();
source.clear();
ExcerptAppender appender = source.createAppender();
appender.startExcerpt(1100 * 1024);
appender.writeObject("TestMessage");
appender.finish();
ExcerptTailer tailer = source.createTailer();
while(!tailer.nextIndex());
Object obj = tailer.readObject();
System.out.println(obj);
tailer.finish();
}
}

在 2015年4月13日星期一 UTC+8下午3:18:05,Peter Lawrey写道:

Rob Austin

unread,
Apr 13, 2015, 5:49:00 AM4/13/15
to java-ch...@googlegroups.com
see 



The try-with-resources statement ensures that each resource is closed at the end of the statement.
Reply all
Reply to author
Forward
0 new messages