SOHU-Co / kafka-node

Node.js client for Apache Kafka 0.8 and later.
MIT License
2.67k stars 628 forks source link

Callback not called when message sending failed by High Level Producer #908

Open haseebnaseem opened 6 years ago

haseebnaseem commented 6 years ago

Questions?

Bug Report

Due to some problem with the cluster, which we are trying to locate, the zookeeperd are throwing the following error

ERROR Failed to send last message. Shutting down thread. (org.apache.zookeeper.server.quorum.QuorumCnxManager)
java.net.SocketException: Socket closed
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:118)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:134)
    at java.io.DataOutputStream.writeInt(DataOutputStream.java:197)
    at org.apache.zookeeper.server.quorum.QuorumCnxManager$SendWorker.send(QuorumCnxManager.java:889)
    at org.apache.zookeeper.server.quorum.QuorumCnxManager$SendWorker.run(QuorumCnxManager.java:916)

Environment

For specific cases also provide

Include Sample Code to reproduce behavior

// include code here
function updateFeedMessage(message){
    producer.send([{topic:'updateFeed',messages:JSON.stringify(message),partition:0}],function(err,data){
        if(err)
            console.log('error in sending update Feed message',err);
        else
            console.log('update feed message sent',data);
    });
}

Include output with Debug turned on

Thanks for your contribution!

hyperlink commented 6 years ago

Have you tried using KafkaClient instead of Client? KafkaClient does not use zookeeper.

haseebnaseem commented 6 years ago

I have tried using that but in that case the client does not detect even when the broker is up after a crash

aikar commented 6 years ago

@haseebnaseem the expectation would be that you would need to handle retrying the send again yourself.

haseebnaseem commented 6 years ago

I understand that if the sending failed, there should be a retrying mechanism however that would only happen if the callback is called with an error.

On Mon, 9 Apr 2018, 23:02 Daniel Ennis, notifications@github.com wrote:

@haseebnaseem https://github.com/haseebnaseem the expectation would be that you would need to handle retrying the send again yourself.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SOHU-Co/kafka-node/issues/908#issuecomment-379840819, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ1EQBptj9a-HbzZ-0jSfX7BMMHaDrpFks5tm6I6gaJpZM4S65jD .

aikar commented 6 years ago

@haseebnaseem that was in reference for if you use KafkaClient, you said you aren't using it since it doesn't detect when its up.

Im saying use KC, and keep retrying.

haseebnaseem commented 6 years ago

My kafka set up does not work without zookeeper, so once its down kafkaClient does not detect its up ever.

On Tue, 10 Apr 2018, 00:09 Daniel Ennis, notifications@github.com wrote:

@haseebnaseem https://github.com/haseebnaseem that was in reference for if you use KafkaClient, you said you aren't using it since it doesn't detect when its up.

Im saying use KC, and keep retrying.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SOHU-Co/kafka-node/issues/908#issuecomment-379860941, or mute the thread https://github.com/notifications/unsubscribe-auth/AJ1EQMcPm7BrJrEWgZWcZiPgyIvh_uXfks5tm7HRgaJpZM4S65jD .