kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Li <da...@stargazer.com.sg>
Subject Re: kafka.common.FailedToSendMessageException: Failed to send messages after 3 tries.
Date Wed, 05 Aug 2015 01:45:11 GMT
you are right.

after I run kafka in my localhost directly, it works just fine

after further google, i found that need to set two parameters below if the
kafka is running on some other machines

#advertised.host.name=<hostname routable by clients>
#advertised.port=<port accessible by clients>

more precisely, if the kafka is running within a docker container, the
advertised.host.name should be set to the docker host ip, the
advertised.port should be set to the mapped port to the docker host.

thanks again.


On Tue, Aug 4, 2015 at 4:58 PM, Jilin Xie <jilinxie1988@gmail.com> wrote:

> Some suggestions:
>          Check the existence of the topic.
>          Check the firewall of the broker... Try telnet or something to
> make sure it's available.
>          Try run the producer on the broker machine.
>
> Since you get this error, this code is functioning. I think it's some
> configuration and parameter stuff leading to this problem.
>
> On Tue, Aug 4, 2015 at 11:21 AM, David Li <david@stargazer.com.sg> wrote:
>
> > Hi I have a very simple code to just send out one message, the topic is
> > created automatically, but the message just cannot be sent out. I also
> > tried to change the configuration, the result is still the same. Sorry to
> > bother you all with this silly question.
> >
> > For your information, the kafka server is running on a docker container,
> > which is run in a ubuntu server vm. The test class is run from IntelliJ
> > IDEA on the host, which is a amc os x.
> >
> > public static void main(String[] args) {
> >         String topic = "test3";
> >
> >         Properties props = new Properties();
> >         props.put("serializer.class", "kafka.serializer.StringEncoder");
> >         props.put("metadata.broker.list", "192.168.144.10:29092");
> > //        props.put("retry.backoff.ms", "1000");
> > //        props.put("message.send.max.retries", "10");
> > //        props.put("topic.metadata.refresh.interval.ms", "0");
> >
> >         Producer<Integer, String> producer = new Producer<Integer,
> > String>(new ProducerConfig(props));
> >
> >         int messageNo = 1;
> >         String messageStr = new String("Message_" + messageNo);
> >         producer.send(new KeyedMessage<Integer, String>(topic,
> > messageStr));
> >     }
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message