簡體   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

我在C ++項目中使用libcurl 7.37.0通過FTP協議與遠程通信。

下面是代碼。

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);

我多次觀察到文件上載由於錯誤代碼28而失敗。

CURLE_OPERATION_TIMEDOUT(28)操作超時。 根據條件達到了指定的超時時間。

我沒有在代碼中設置任何超時,經過大量搜索之后,我知道我們可以使用CURLOPT_TIMEOUT設置超時值,默認情況下,它的值為0,直到完成相應的操作時才超時,就我而言,我執行了文件上傳操作。

通過Wireshark日志后,我發現從端口20啟動數據傳輸時,我看到libcurl在沒有任何已知原因的情況下向端口21發送了[FIN,ACK] ,因為該遠程將響應代碼426(傳輸中止)發送給了libcurl,它將28個錯誤代碼返回給應用程序。

請檢查具有導線痕跡的圖像。

源IP:18是Linux服務器,目標IP:36是Windows遠程系統

在此處輸入圖片說明

此問題是隨機發生的。 誰能知道原因和避免此問題的方法。

發生此問題時,重置curl上下文CurlSessionHandle並重新初始化。 這可能有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM