@@ -278,7 +278,7 @@ ClientConnection::~ClientConnection() {
278
278
void ClientConnection::handlePulsarConnected (const proto::CommandConnected& cmdConnected) {
279
279
if (!cmdConnected.has_server_version ()) {
280
280
LOG_ERROR (cnxString_ << " Server version is not set" );
281
- close (ResultUnknownError );
281
+ close ();
282
282
return ;
283
283
}
284
284
@@ -451,7 +451,7 @@ void ClientConnection::handleTcpConnected(const ASIO_ERROR& err, tcp::resolver::
451
451
Url service_url;
452
452
if (!Url::parse (physicalAddress_, service_url)) {
453
453
LOG_ERROR (cnxString_ << " Invalid Url, unable to parse: " << err << " " << err.message ());
454
- close (ResultInvalidUrl );
454
+ close ();
455
455
return ;
456
456
}
457
457
}
@@ -489,7 +489,12 @@ void ClientConnection::handleTcpConnected(const ASIO_ERROR& err, tcp::resolver::
489
489
}
490
490
});
491
491
} else {
492
- close (ResultRetryable);
492
+ if (err == ASIO::error::operation_aborted) {
493
+ // TCP connect timeout, which is not retryable
494
+ close ();
495
+ } else {
496
+ close (ResultRetryable);
497
+ }
493
498
}
494
499
} else {
495
500
LOG_ERROR (cnxString_ << " Failed to establish connection: " << err.message ());
@@ -499,8 +504,8 @@ void ClientConnection::handleTcpConnected(const ASIO_ERROR& err, tcp::resolver::
499
504
500
505
void ClientConnection::handleHandshake (const ASIO_ERROR& err) {
501
506
if (err) {
502
- LOG_WARN (cnxString_ << " Handshake failed: " << err.message ());
503
- close (ResultRetryable );
507
+ LOG_ERROR (cnxString_ << " Handshake failed: " << err.message ());
508
+ close ();
504
509
return ;
505
510
}
506
511
@@ -527,7 +532,7 @@ void ClientConnection::handleSentPulsarConnect(const ASIO_ERROR& err, const Shar
527
532
}
528
533
if (err) {
529
534
LOG_ERROR (cnxString_ << " Failed to establish connection: " << err.message ());
530
- close (ResultRetryable );
535
+ close ();
531
536
return ;
532
537
}
533
538
@@ -562,14 +567,14 @@ void ClientConnection::tcpConnectAsync() {
562
567
std::string hostUrl = isSniProxy_ ? proxyServiceUrl_ : physicalAddress_;
563
568
if (!Url::parse (hostUrl, service_url)) {
564
569
LOG_ERROR (cnxString_ << " Invalid Url, unable to parse: " << err << " " << err.message ());
565
- close (ResultInvalidUrl );
570
+ close ();
566
571
return ;
567
572
}
568
573
569
574
if (service_url.protocol () != " pulsar" && service_url.protocol () != " pulsar+ssl" ) {
570
575
LOG_ERROR (cnxString_ << " Invalid Url protocol '" << service_url.protocol ()
571
576
<< " '. Valid values are 'pulsar' and 'pulsar+ssl'" );
572
- close (ResultInvalidUrl );
577
+ close ();
573
578
return ;
574
579
}
575
580
@@ -588,7 +593,7 @@ void ClientConnection::handleResolve(const ASIO_ERROR& err, tcp::resolver::itera
588
593
if (err) {
589
594
std::string hostUrl = isSniProxy_ ? cnxString_ : proxyServiceUrl_;
590
595
LOG_ERROR (hostUrl << " Resolve error: " << err << " : " << err.message ());
591
- close (ResultConnectError );
596
+ close ();
592
597
return ;
593
598
}
594
599
@@ -624,8 +629,8 @@ void ClientConnection::handleResolve(const ASIO_ERROR& err, tcp::resolver::itera
624
629
}
625
630
});
626
631
} else {
627
- LOG_ERROR (cnxString_ << " No IP address found" );
628
- close (ResultConnectError );
632
+ LOG_WARN (cnxString_ << " No IP address found" );
633
+ close ();
629
634
return ;
630
635
}
631
636
}
@@ -880,7 +885,7 @@ void ClientConnection::handleIncomingCommand(BaseCommand& incomingCmd) {
880
885
// Handle Pulsar Connected
881
886
if (incomingCmd.type () != BaseCommand::CONNECTED) {
882
887
// Wrong cmd
883
- close (ResultRetryable );
888
+ close ();
884
889
} else {
885
890
handlePulsarConnected (incomingCmd.connected ());
886
891
}
0 commit comments