0 votes
by (120 points)
edited

My company uses Rebex SFTP to ftp files which is working great from an ftp perspective, however, when called from a WebMethod the service never returns. Below is how our process flow is working.

  1. WebMethod is invoked by some other system
  2. WebMethod calls another class in the same project that queries the database for a list of files to be ftp-ed.
  3. This class calls an FTP.cs that uses sftp to copy the file (via DownloadFile)
  4. All files successfully ftp from and to the desired locations, however, the web method never returns and eventually times out.

The web service is supposed to return a string. If I put a break point on the return the breakpoint gets hit with all of the values I am expecting, however, the caller never gets the string from the response.

I am not sure if I am doing something wrong, or if the Rebex.SFTP class was never intended to be invoked from a web method but any advice would be great. Thanks!

Here is my code setup:

    public class FTP
    {
        private Sftp _sftp;
        ...

        public string DownloadFile(string fileName, string ext) {
           ...

            if (_sftp.GetFile(fileName, myNewPath) <= 0)
            {
                //failed
            }
            else
            {
               //success
            }
        }
    }
Applies to: Rebex FTP/SSL, Rebex SFTP
by (18.1k points)
edited

Do you call a synchronous variant of the Download method or the asynchronous DownloadAsync?

Anyway, could you create a communication log according to this article and post it here or send it to support@rebex.net? We would find a clue, where the SFTP communication ends.

by (120 points)
edited

Hi Jan, thank you for your response.

My code calls a class called FTP which I added to my question above. I presume I am calling the synchronous variant. All requested files copy properly, the web service caller just never gets a response (except for an eventual timeout)

by (13.3k points)
edited

There is an ASP.NET FTP sample in your download package. It does not use WebMethods, but it's pretty close. Let's try to rule out a network/IIS/firewall issue. Does this sample work in your environment? The sample is described here: http://www.rebex.net/sample/ftp-asp-client/default.aspx

2 Answers

0 votes
by (15.2k points)
edited

Hi,

I have sent you an email with a testing projects which works in our environment. Give it a try and let us know if it works for you as well.

0 votes
by (15.2k points)
edited

Hi, I have some ideas what may help you solve the issue.

Please try to return string constant from the service without using the SFTP comunication part. This may help to recognize network or configuration issue.

You wrote that the service times out but the method finished (a breakpoint on the return statemetn got hit). This may be the case that the IIS/web server times out the response, but the method does not finished already. Something like: web server timeout = 60s, web service method duration = 90s. If the method does not fail, it finished even though the server times out. This may be caused by large files you want to download. If it is possible, try to download your files asynchronously by calling either Sftp.BeginDownload or Sftp.DownloadAsync depending on .NET you are on.

...