I usually got that exception if

a) there is a firewall issue

b) you are trying to consume messages from another node and have not set
your advertised host name to the public ip address in the kafka server
settings.



On Tue, Feb 24, 2015 at 12:07 PM, alexey yakubovich <
alexe...@yahoo.com.invalid> wrote:

> Hi,  I am learning kafka, ... hard way
> I try to run the example given here:
> https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+SimpleConsumer+Example
> Whatever I do i I have
>     java.nio.channels.ClosedChannelException when try to send message
> Exception in thread "main" java.nio.channels.ClosedChannelExceptionat
> kafka.network.BlockingChannel.send(BlockingChannel.scala:100)at
> kafka.consumer.SimpleConsumer.liftedTree1$1(SimpleConsumer.scala:78)at
> kafka.consumer.SimpleConsumer.kafka$consumer$SimpleConsumer$$sendRequest(SimpleConsumer.scala:68)
> And, sometimes it's
>     2015-02-24 13:46:51 INFO  SimpleConsumer:68 - Reconnect due to socket
>     error: java.io.EOFException: Received -1 when reading from channel,
> socket     has likely been closed.
> (in all cases it fails in findLeader())
>
>
> At the same some other consumers work, as e.g. the command line
> console-consumer
> Now, I put a very small code snippet (below), that seems should do the
> job, but it's not, something missing. Please help.
> public class Test1  {    public static void main(String[] args)   {String
> host = "localhost";  int port = 2181;  String topic = "test";  int
> soTimeout = -1;  int bufferSize = 100000;  String clientId = "me-aly";
> SimpleConsumer consumer = new SimpleConsumer(host, port, soTimeout,
> bufferSize, clientId);List<String> topics =
> Collections.singletonList(topic);
> TopicMetadataRequest req = new TopicMetadataRequest(topics);
>   kafka.javaapi.TopicMetadataResponse resp = consumer.send(req);
> System.out.println(resp); }}
>
>

Reply via email to