-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPP SDK did not respond to request 307 during lookup #12888
Comments
ping @BewareMyPower PTAL thanks |
It looks like the C++ client has configured the URL redirection, see pulsar/pulsar-client-cpp/lib/HTTPLookupService.cc Lines 182 to 184 in b807200
And it's weird that you log is
See https://curl.se/libcurl/c/libcurl-errors.html
Could you try following C++ code and see what would happen? #include <curl/curl.h>
#include <iostream>
#include <string>
static size_t curlWriteCallback(void *contents, size_t size, size_t nmemb,
void *responseDataPtr) {
((std::string *)responseDataPtr)->append((char *)contents, size * nmemb);
return size * nmemb;
}
int main() {
std::string completeUrl =
"http://1.62.3.1:1001/lookup/v2/topic/persistent/pulsar-q4822m9k7ej8/test-ns/test-topic-1-partition-30";
std::string header =
"Authorization: Bearer eyJrZXlJZCI6InB1bHNhci1xcccccxxxxx";
CURL *handle = curl_easy_init();
if (!handle) {
return 1;
}
// set URL
curl_easy_setopt(handle, CURLOPT_URL, completeUrl.c_str());
// Write callback
std::string responseData;
curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curlWriteCallback);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, &responseData);
// New connection is made for each call
curl_easy_setopt(handle, CURLOPT_FRESH_CONNECT, 1L);
curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1L);
// Skipping signal handling - results in timeouts not honored during the DNS
// lookup
curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
// Timer
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 3);
// Set User Agent
curl_easy_setopt(handle, CURLOPT_USERAGENT, "Pulsar-CPP-v2.8.0");
// Redirects
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(handle, CURLOPT_MAXREDIRS, 20);
// Fail if HTTP return code >=400
curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1L);
struct curl_slist *list = NULL;
list = curl_slist_append(list, header.c_str());
curl_easy_setopt(handle, CURLOPT_HTTPHEADER, list);
char errorBuffer[CURL_ERROR_SIZE];
curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errorBuffer);
curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "GET");
auto res = curl_easy_perform(handle);
std::cout << "Result: " << res << ", error: " << errorBuffer << std::endl;
long httpResponseCode;
curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &httpResponseCode);
std::cout << "HTTP response code: " << httpResponseCode << std::endl;
curl_easy_cleanup(handle);
std::cout << "Content:\n" << responseData << std::endl;
return 0;
} You need to modify For example, in my local env, the output could be
|
When i run the code, return |
In here, i try to run
|
Describe the bug
A normal broker cluster, suppose I now create a topic with 128 partitions to ensure that each broker node is distributed with a certain number of partitions. At this time, start the cpp client to send and consume data, everything is normal.
At this point, we kill one of the brokers and restart the broker. We can see that the cpp sdk keeps reporting the following error
Since it is using HTTP Lookup service, it uses the libcurl warehouse. At this time, we use the curl command locally to simulate the processing behavior of the cpp code:
We got the following wrong output:
At this point, we continue to use curl to execute the Location returned last time, as follows:
Output as follows:
Through the return value, we can see that the broker returned the correct owner broker address to the cpp client, but the cpp sdk did not respond to the 307 request, causing the lookup to continue to fail.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: