diff --git a/lib/ClientConnection.cc b/lib/ClientConnection.cc index 0641809e..3fb1684e 100644 --- a/lib/ClientConnection.cc +++ b/lib/ClientConnection.cc @@ -1469,10 +1469,15 @@ Future ClientConnection::newGetSchema(const std::string& top return promise.getFuture(); } -void ClientConnection::checkServerError(ServerError error) { +void ClientConnection::checkServerError(ServerError error, const std::string& message) { switch (error) { case proto::ServerError::ServiceNotReady: - close(ResultDisconnected); + // See + // https://github.com/apache/pulsar/blob/1952f94769d9dc80908d159be6e6ce1ff48b83fb/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookupBase.java#L334 + // These errors should be retryable and we should not close the connection + if (message.find("Failed to lookup") != std::string::npos) { + close(ResultDisconnected); + } break; case proto::ServerError::TooManyRequests: // TODO: Implement maxNumberOfRejectedRequestPerConnection like @@ -1573,7 +1578,7 @@ void ClientConnection::handlePartitionedMetadataResponse( << partitionMetadataResponse.request_id() << " error: " << partitionMetadataResponse.error() << " msg: " << partitionMetadataResponse.message()); - checkServerError(partitionMetadataResponse.error()); + checkServerError(partitionMetadataResponse.error(), partitionMetadataResponse.message()); lookupDataPromise->setFailed( getResult(partitionMetadataResponse.error(), partitionMetadataResponse.message())); } else { @@ -1650,7 +1655,7 @@ void ClientConnection::handleLookupTopicRespose( LOG_ERROR(cnxString_ << "Failed lookup req_id: " << lookupTopicResponse.request_id() << " error: " << lookupTopicResponse.error() << " msg: " << lookupTopicResponse.message()); - checkServerError(lookupTopicResponse.error()); + checkServerError(lookupTopicResponse.error(), lookupTopicResponse.message()); lookupDataPromise->setFailed( getResult(lookupTopicResponse.error(), lookupTopicResponse.message())); } else { diff --git a/lib/ClientConnection.h b/lib/ClientConnection.h index 851ec0c3..b16fc694 100644 --- a/lib/ClientConnection.h +++ b/lib/ClientConnection.h @@ -404,7 +404,7 @@ class PULSAR_PUBLIC ClientConnection : public std::enable_shared_from_this