[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FTPAPI Timed out after large number of PUTs



Thanks for the great API

 

I have posted my version of MPUT using the FTPAPI below to give something back to the group and to ask for help.

 

The purpose is to MPUT the contents of a directory and optionally move the file to a different directory or delete it but only if the PUT was successful.

The program below also uses Toms BASICS1 and IFS  service programs for directory and file manipulation.

 

The program opens the FTP session, sets Binary *on and Passive *off

 

It then reads a directory entry and PUTs the file.

Reads the next directory  entry and PUTs until the all entries have been read.

 

Now the problem.  I am transferring over 1000 files for about 10 meg of data.

The program would hang after transferring 300 (not always the same number) or more files successfully so I added the 15 second socket timeout.

The program regains control but does not recover after the quit and connect,  It cannot reconnect so it ends.

This transfer is AS/400 to AS/400 internet speed probably 128k or less.

 

The disconnects seem to happen 5, 10, or 15 minutes after initial connection.

My theory is that some ISP along the way is not seeing traffic on port 80 thinks it is inactive and closes the connection.

 

Weather my theory is correct or not how can I get the program to recognize the connection is lost establish a new one and just continue on???

 

I have included the last portion of the job log so you can see what is happening in the current program.

 

Joel Rose

Sr programmer analyst

Solutions, Inc.

Spencer Iowa

 

 

 

250 File transfer completed successfully.                   

> TYPE I                                                    

200 Representation type is binary IMAGE.                    

> PORT 10,0,0,1,24,202                                      

200 PORT subcommand request successful.                     

> STOR /lcm/CTY74_20050211_112225392_1764.xml               

DSPLY  Timed out while waiting for data from socket            ********** connection times out

> QUIT                                                      

150 Sending file to /lcm/CTY74_20050211_112225392_1764.xml  

220-QTCP at WEB4002.xxxxxxxx.COM.                       

220 Connection will close if idle more than 5 minutes.      

> USER webxxxxx                                            

DSPLY  Timed out while waiting for data from socket    

 

 

*===============================================================*   

H DEBUG                                                              

H OPTION(*SRCSTMT : *NODEBUGIO)                                      

H DECEDIT('0,') DATEDIT(*DMY.)                                        

H DATFMT(*ISO )  TIMFMT(*ISO )                                       

H DFTACTGRP(*NO)                                                     

H ACTGRP(*NEW)                                                       

H EXPROPTS(*RESDECPOS)                                               

H EXTBININT(*YES)                                                    

H BNDDIR('QC2LE':'XMLRPG':'FTPAPI')                                  

 *===============================================================*   

 *                                                                   

 * ------------------------------------                              

 *  XML Wrapper Service Program                                       

 * ------------------------------------                              

 /COPY QXMLRPG,PXMLRPG                                               

 * ------------------------------------                              

 *  Basics                                                            

 * ------------------------------------                              

 /COPY QBASICS1,PBASICS1                                                    

 * ------------------------------------                                      

 *  FTPAPI Service Program                                                  

 * ------------------------------------                                     

 /COPY FTPAPISRC,FTPAPI_H                                                    

 /COPY QIFS,CLIB                                                            

 /COPY QIFS,PIFS                                                            

D Msg             S             52A                                         

D sess            S             10I 0                                       

 *                                                                          

 * ------------------------------------                                     

 *  Internal prototypes                                                      

 * ------------------------------------                                     

 *                                                                          

D PGM_ENTRY_POINT...                                                         

D                 PR                  extpgm('FTPMPUTR')                    

D   p_conn                      30A   const                                 

D   p_user                      20A   const                                 

D   p_pass                      20A   const                                 

D   p_from                     120A   const                       

D   p_to                       120A   const                       

D   p_move                     120A   const                       

                                                                  

D   w_to          s            256A                               

D   w_from        s            256A                                

D   w_move        s            256A                               

D  i_dirp         s               *                               

D  rc             S             10I 0                   inz       

D  Error_count    S              5P 0                             

 *                                                                

 *===============================================================*

 *  Program-Entry-Point                                           

 *===============================================================*

D PGM_ENTRY_POINT...                                              

D                 PI                                              

D   p_conn                      30A   const                       

D   p_user                      20A   const                       

D   p_pass                      20A   const                       

D   p_from                     120A   const                     

D   p_to                       120A   const                      

D   p_move                     120A   const                     

 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 /FREE                                                          

                                                                 

  // connect to FTP server.  If an error occurs,                

  // display an error message and exit.                         

          sess = ftp_conn(%trim(p_conn):                        

                 %trim(p_user):                                  

                 %trim(p_pass):                                 

                 21:                                            

                 15);                                           

      if sess < 0;                                              

        Msg = ftp_error;                                        

        dsply Msg;                                              

        *inlr = *on;                                             

        return;                                                 

      endif;                                                    

                                                                    

      rc = ftp_passiv('0');                                          

      callp ftp_binary(*on);                                        

                                                                    

  // Read directory  Process all responses.                         

   i_dirp = opendir(%trim(p_from));                                 

   if   f_errno <> 0;                                               

      msg = f_newMsg('CPF9898': f_strerror(f_errno));               

   endif;                                                            

   p_dirent = readdir(i_dirp);                                      

   dow  p_dirent <> *null;                                          

   if   f_errno <> 0;                                               

      msg = f_newMsg('CPF9898': f_strerror(f_errno));               

   endif;                                                           

     if (dirent_t.d_namelen) > 3;                                   

                                                                    

    w_to = %trim(p_to) + '/' +                                      

                 %subst((dirent_t.d_name):1:(dirent_t.d_namelen));  

    w_from = %trim(p_from) + '/' +                                  

                 %subst((dirent_t.d_name):1:(dirent_t.d_namelen));  

                                                                    

    if ftp_put(sess: %trim(w_to) : %trim(w_from) ) < 0;             

       Msg = ftp_error;                                             

       dsply Msg;                                                   

                                                                    

  // Error Recovery  Disconnect and Reconnect                       

  // If unsuccessfull terminate                                      

                                                                    

    callp ftp_quit(sess);                                           

          sess = ftp_conn(%trim(p_conn):                            

                 %trim(p_user):                                     

                 %trim(p_pass):                                     

                 21:                                                

                 15);                                                

      if sess < 0;                                                  

        Msg = ftp_error;                                            

        dsply Msg;                                                  

        *inlr = *on;                                                 

        return;                                          

      endif;                                             

                                                         

      rc = ftp_passiv('0');                               

      callp ftp_binary(*on);                             

                                                         

      iter;                                              

                                                         

    else;                                                 

      if p_move <> *blanks;                              

        if p_move = '*DELETE';                           

          rc = unlink(%trim(w_from));                    

        else;                                            

                                                         

       rc = f_moveIfsFile(%trim(w_from): %trim(p_move)); 

                                                         

        endif;                                            

      endif;                                             

    endif;                                               

    endif;                    

   p_dirent = readdir(i_dirp);

   enddo;                     

                               

    callp ftp_quit(sess);     

                              

    *INLR = *ON;              

                              

 /END-FREE