BewareMyPower commented on code in PR #577:
URL: https://github.com/apache/pulsar-client-cpp/pull/577#discussion_r3256071797
##########
lib/ConsumerImpl.cc:
##########
@@ -371,8 +371,9 @@ Result ConsumerImpl::handleCreateConsumer(const
ClientConnectionPtr& cnx, Result
}
if (consumerCreatedPromise_.isComplete()) {
- // Consumer had already been initially created, we need to retry
connecting in any case
+ // Clear the connection set before SUBSCRIBE so the next reconnect
is not skipped.
LOG_WARN(getName() << "Failed to reconnect consumer: " <<
strResult(result));
+ resetCnx();
Review Comment:
The fix here is okay for consumer path. But a thorough solution is to reset
the internal states of `HandlerBase` when `connectionOpened` fails.
See the Java client implementation:
1.
https://github.com/apache/pulsar/blob/8f9f5b49d631e235e86d79e48a63722e74db4413/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionHandler.java#L148
2.
https://github.com/apache/pulsar/blob/8f9f5b49d631e235e86d79e48a63722e74db4413/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionHandler.java#L173
3.
https://github.com/apache/pulsar/blob/8f9f5b49d631e235e86d79e48a63722e74db4413/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionHandler.java#L179-L180
The `cnx` is reset to null and `duringConnect` is reset to false if
`connectionOpened` failed. This change is effectively same with
`resetCnx(nullptr)` in C++ client
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]