简体   繁体   English

C ++ Libcurl:将文件从linux系统传输到Windows远程系统时,curl_easy_perform返回错误代码28

[英]C++ Libcurl: curl_easy_perform returned error code 28 when transferring files from linux system to windows remote system

I'm using libcurl 7.37.0 in my C++ project to communicate with remote by FTP protocol. 我在C ++项目中使用libcurl 7.37.0通过FTP协议与远程通信。

below is the code. 下面是代码。

curl_easy_setopt(CurlSessionHandle, CURLOPT_URL, remoteFileUrl);
curl_easy_setopt(CurlSessionHandle, CURLOPT_UPLOAD, ON);

// Set the input local file handle
curl_easy_setopt(CurlSessionHandle, CURLOPT_READDATA, localFileHandle);

// Set on/off all wanted options
// Enable ftp data connection
curl_easy_setopt(CurlSessionHandle, CURLOPT_NOBODY, OFF);

// Create missing directory into FTP path
curl_easy_setopt(CurlSessionHandle, CURLOPT_FTP_CREATE_MISSING_DIRS , ON) ;

// Set the progress function, in order to check the stop transfer request
curl_easy_setopt(CurlSessionHandle, CURLOPT_NOPROGRESS, OFF);
curl_easy_setopt(CurlSessionHandle, CURLOPT_PROGRESSFUNCTION, progressCb);
curl_easy_setopt(CurlSessionHandle, CURLOPT_PROGRESSDATA, this);

CURLcode Result = curl_easy_perform(CurlSessionHandle);

many times i have observed uploading of files is failing due to error code 28 . 我多次观察到文件上载由于错误代码28而失败。

CURLE_OPERATION_TIMEDOUT (28) Operation timeout. CURLE_OPERATION_TIMEDOUT(28)操作超时。 The specified time-out period was reached according to the conditions. 根据条件达到了指定的超时时间。

i didn't set any timeout in the code, after doing a lot of search i came to know we can use CURLOPT_TIMEOUT to set the timeout value, by default it's value is 0 where it doesn't timeout until it finishes the respective operation, in my case i performed file upload operation. 我没有在代码中设置任何超时,经过大量搜索之后,我知道我们可以使用CURLOPT_TIMEOUT设置超时值,默认情况下,它的值为0,直到完成相应的操作时才超时,就我而言,我执行了文件上传操作。

after going through the wireshark logs, i have observed that when data transfer is initiated from port 20, i see libcurl sends [FIN,ACK] without any known reason to port 21, because of that remote sends response code 426(transfer aborted) to libcurl and it returns 28 error code to application. 通过Wireshark日志后,我发现从端口20启动数据传输时,我看到libcurl在没有任何已知原因的情况下向端口21发送了[FIN,ACK] ,因为该远程将响应代码426(传输中止)发送给了libcurl,它将28个错误代码返回给应用程序。

Please check the image which has wireshark traces. 请检查具有导线痕迹的图像。

Source IP: 18 is Linux server & Destination IP: 36 is Windows remote system 源IP:18是Linux服务器,目标IP:36是Windows远程系统

在此处输入图片说明

This problem is happening randomly. 此问题是随机发生的。 Could anyone know the reason & a way to avoid this problem. 谁能知道原因和避免此问题的方法。

When this issue occurs, reset the curl context CurlSessionHandle and re initialize it. 发生此问题时,重置curl上下文CurlSessionHandle并重新初始化。 This might work. 这可能有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM