pulsar-client-node icon indicating copy to clipboard operation
pulsar-client-node copied to clipboard

Event listener if client disconnect or connection interruption

Open iamrmin opened this issue 4 years ago • 4 comments

It would be great to have a callback at Client level that trigger if connection break in-between.

iamrmin avatar Feb 22 '21 17:02 iamrmin

@iamrmin If the connection is disconnected from the server side, the client will automatically reconnect and the application should not need to detect it. Could you tell me why you need such a callback?

massakam avatar Feb 25 '21 03:02 massakam

@massakam ok but what if it takes hours and days to reconnect. Though I am not sure what is a timeout my concern here is healthcheck. It somehow should be know that pulsar is down and i am looking for any kind of callback.

iamrmin avatar Feb 25 '21 05:02 iamrmin

@iamrmin On the producer side, we should be able to notice that the connection has been lost because message sending times out (the duration can be changed with the sendTimeoutMs property) and an exception is thrown. On the consumer side, there is currently no way to notice that the connection has been lost except by looking at the error log.

The Node.js client is a wrapper of Pulsar C++ client and the C++ client doesn't have such feature. So it is currently difficult to implement such a callback...

massakam avatar Feb 26 '21 05:02 massakam

@massakam I see. Thank you :)

iamrmin avatar Feb 26 '21 05:02 iamrmin