Hi Daniel,
Thanks for suggestions. We will work on upgrade.

Regarding disconnection, here is code flow -
1. Authentication to server successful.
2. Opening data channel for File download from server
3. after 2 minutes, connection timed out.

Sample code -
       initMultiHandle();
        // initiate download
        auto l_easy = initEasyHandle();
        if (l_easy)
        {
            l_result = curl_multi_add_handle(m_multi, l_easy);
        }
        else
        {
            Error
        }
    

bool initMultiHandle()
{
    auto l_result = CURLM_OK;

                m_multi = curl_multi_init();

            curl_multi_setopt(
                m_multi, CURLMOPT_SOCKETFUNCTION, 
(curl_socket_callback)[](auto, auto a_socket, auto a_action, auto a_client, 
auto) {
                    return CURL_CLIENT(a_client)->socketCallback(a_socket, 
a_action);
                });
            curl_multi_setopt(m_multi, CURLMOPT_SOCKETDATA, this);
            curl_multi_setopt(
                m_multi, CURLMOPT_TIMERFUNCTION, 
(curl_multi_timer_callback)[](auto, auto a_interval, auto a_client) {
                    return 
CURL_CLIENT(a_client)->updateTimeoutCallback(a_interval);
                });
            curl_multi_setopt(m_multi, CURLMOPT_TIMERDATA, this);
   
    return l_result = CURLM_OK;
}


CURL initEasyHandle()
{

    auto l_easy{curl_easy_init()};

        // basic stuff
        curl_easy_setopt(l_easy, CURLOPT_URL, <URL>);
        curl_easy_setopt(l_easy, CURLOPT_USERNAME, <USER>);
        curl_easy_setopt(l_easy, CURLOPT_PASSWORD, <PWD>);
        curl_easy_setopt(l_easy, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD);
        //curl_easy_setopt(l_easy, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
        curl_easy_setopt(l_easy, CURLOPT_FOLLOWLOCATION, 1L);
        curl_easy_setopt(l_easy, CURLOPT_CONNECTTIMEOUT, 20L);
        curl_easy_setopt(l_easy, CURLOPT_LOW_SPEED_LIMIT, 1L);
        curl_easy_setopt(l_easy, CURLOPT_LOW_SPEED_TIME, 30L);
        curl_easy_setopt(l_easy, CURLOPT_TIMEOUT, 1510L);
        curl_easy_setopt(l_easy, CURLOPT_BUFFERSIZE, 512000L);

        // writing
        curl_easy_setopt(
            l_easy, CURLOPT_WRITEFUNCTION, (curl_write_callback)[](auto a_data, 
auto, auto a_size, auto a_client) {
                return CURL_CLIENT(a_client)->writeCallback(a_data, a_size);
            });
        curl_easy_setopt(l_easy, CURLOPT_WRITEDATA, this);

        // logging
        curl_easy_setopt(l_easy, CURLOPT_VERBOSE, 1L);
        curl_easy_setopt(
            l_easy, CURLOPT_DEBUGFUNCTION, (curl_debug_callback)[](auto, auto 
a_type, auto a_data, auto, auto a_client) {
                return CURL_CLIENT(a_client)->logCallback(a_type, a_data);
            });
        curl_easy_setopt(l_easy, CURLOPT_DEBUGDATA, this);

        // progress
        curl_easy_setopt(
            l_easy, CURLOPT_XFERINFOFUNCTION, (curl_xferinfo_callback)[](auto 
a_client, auto a_total, auto a_now, auto, auto) {
                return CURL_CLIENT(a_client)->progressCallback(a_total, a_now);
            });
        curl_easy_setopt(l_easy, CURLOPT_XFERINFODATA, this);
        curl_easy_setopt(l_easy, CURLOPT_NOPROGRESS, 0L);
    }
    return l_easy;
}

Regards,
Vaibhav Taksale

-----Original Message-----
From: Daniel Stenberg <dan...@haxx.se> 
Sent: Wednesday, 25 August, 2021 12:04
To: vaibhav.taksale--- via curl-library <curl-library@cool.haxx.se>
Cc: Taksale Vaibhav (M) <vaibhav.taks...@external.marelli.com>
Subject: RE: Connection to file server disconnected while file transfer is in 
progress

On Wed, 25 Aug 2021, vaibhav.taksale--- via curl-library wrote:

> [Vaibhav] Libcurl version 7.58 Used on Embedded Linux platform on ar758x 
> board.

This should come as no surprise but of course my first recommendation will be 
to upgrade your libcurl to a recent release as whatever problem you experience 
it is most likely addressed (or different) then.

> e.g. In this function callback "writeCallback", error return was expected.

I don't understand. The callback is your code. You make it return error!

-- 

  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to