通过多个线程将消息发送到curl,并且偶尔会出现以下错误之一。
curl_easy_perform():失败的ssl连接错误。 sschannel:next initializesecuritycontext failed:SEC_E_MESSAGE_ALTERED
curl_easy_perform():失败的ssl连接错误。 sschannel:next initializesecuritycontext failed:SEC_E_BUFFER_SMALL
截至目前,我正在通过重新发送请求来解决这个问题。但是为什么会发生这种错误(在接下来的40秒内发出相同的请求)以及可以采取哪些措施来避免这种情况。
源代码是用C ++编写的。 LibCurl是使用Microsoft visual studio 2010构建的。以下是调用curl库的代码。
CURL *curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "connection-page");
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestToPost.c_str());
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(requestToPost.c_str()));
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerInfo);
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_data);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curlErrorbuffer);
std::stringstream resPonseInfo;
std::stringstream headerResponse;
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &resPonseInfo);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headerResponse);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
res = curl_easy_perform(curl);
if ((res != CURLE_OK))
{
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
std::cout << "Request === " << std::endl;
std::cout << requestToPost << std::endl;
std::cout << "Error === " << std::endl;
std::cout << curlErrorbuffer << std::endl;
std::cout << "Header == " << std::endl << headerResponse.str() << std::endl;
std::cout << "Response == " << std::endl << resPonseInfo.str() << std::endl;
}
else // if(res == CURLE_OK)
{
std::cout << "Response from the http post was successful " << std::endl;
responseInfo = resPonseInfo.str();
}
curl_easy_cleanup(curl);
curl = NULL;
}
“通过多个线程发送消息卷曲......” - 给出描述的症状最合乎逻辑的是假设多线程相关问题