[SFTP] Discussion

[SFTP] Discussion

  
Forge Component
(3)
Published on 24 Sep by Wei Zhu
3 votes
Published on 24 Sep by Wei Zhu
I've created a new version to allow to perform a GET directly from the local file system, as well as a PUT and thought of sharing with someone who might need it!

Instead of adding another extension to perform the save to File System, with this version there are two new methods that handle this directly. The methods are GetToFS and PutFromFS.

This has been made in version 7.0 of the Integration Studio, but should be easily ported to previous versions.

If you have any issues or questions please let me know.
Hi João,

I'm trying to generate a XML file and put it into the FTP directory using the PUT command and i keep getting same error. I tried several different ways but no luck, can you help me out here?

FTP: ftp://mail.maeil.pt

Arguments on PUT function:
  • HOST: "mail.maeil.pt"
  • PORT: 21
  • PATH: "/"
  • DATA: "TextToBinaryData(xml,Encoding:"utf-8")"
The file is ok, i tried downloading this before passing it to the FTP and it comes out fine. I also tried with a second FTP, but i keep getting the same error "An existing connection was forcibly closed by the remote host". What am i doing wrong here?
Hi,

today i tried using a SSH client, FileZilla, to connect to the same FTP and it's working fine. I also tried to do LIST command and i still get same error. Any ideas?

Thanks!
Hi Pedro,

Can you give a try using the PutFromFS Action and let me know if the result is the same? For this action you should pass a absolute file path on the server side.

Is there any specific option in Filezilla that you can set up that makes the response the same?

Regards,
João.
To test this with the PutFromFS Action, and looking to the arguments i mentioned before for the same FTP, should it be something like this:
  • HOST: "mail.maeil.pt"
  • PORT: 21
  • PATH: "/Name_of_File.xml"
  • LOCALFILE: "Name_of_File.xml"
or am i supposed to put something different in the PATH and LOCALFILE? By the way, the xml file is a local variable of text type and since it's not accepting the "TextToBinaryData(xml,Encoding:"utf-8")" anymore i'm not sure if this is the correct way of testing it. How should i test it?
FYI,

i tried with:
  • HOST: "mail.maeil.pt"
  • PORT: 21
  • PATH: "/xml.xml"
  • LOCALFILE: "xml"
being XML the local variable of type text and it gave same error.
Hi Pedro,

There seems to be a (plain) FTP server at ftp://mail.maeil.pt/.

However, this extension is meant to be used with SSH FTP - not plain FTP. Are you sure this is what you need? If you need to use plain FTP, check out this other extension:
http://www.outsystems.com/NetworkForge/ProjectDetail.aspx?ProjectId=59

If you *really* need SFTP (perhaps available on another port - I believe default it 22), try to connect to a local test server first, to put aside eventual network issues. Core FTP has a free 'mini' version (run only, no install):
http://www.coreftp.com/server/download/msftpsrvr.exe

Also note that you can use the included .Net tester in the SFTP extension (SFTP\Source\SFTPTester\bin\Release\SFTPTester.exe) to test connectivity, before going into ServiceStudio.
Hi Paulo,

The dates returned by the method List are in Text format and are being set with the .toString() method.

Since the .toString() from a DateTime format is dependent from the CurrentCulture, which can be different between environments, it was not straight-forward to map those dates to a DateTime variable in ServiceStudio in order to be consistent between environments.

Due to this, I've changed List method to return the dates directly in the format DateTime which will be in the format defined in the Environment Configuration.

NOTE: This version is based on the published Version 2.0.
Cool!
Do you want to upload the new version, so the Community members don't miss it? Just click the 'Join the Team' button in the component details, so you can upload it later.

Cheers,
Paulo
I'm getting an error when trying to PUT files larger than 32KB:

Timer ExportTerritoriesFile error (inside action 'TerritoriesExport'). Timer duration = 30 secs:Payload cannot be more then 32768 bytes. [retry 1 of 3 scheduled]
Stack:
System.InvalidOperationException: Payload cannot be more then 32768 bytes.
   at ssGemPortalLoader.RssExtensionSFTP.MssPut(HeContext heContext, String inParamHost, Int32 inParamPort, String inParamUsername, String inParamPassword, String inParamPath, Byte[] inParamData)
   at ssGemPortalLoader.Actions.ActionPut(HeContext heContext, String inParamHost, Int32 inParamPort, String inParamUsername, String inParamPassword, String inParamPath, Byte[] inParamData)
   at ssGemPortalLoader.Actions.ActionTerritoriesExport(HeContext heContext)
   at ssGemPortalLoader.TimerExportTerritoriesFile.Execute(HeContext heContext, Int32 timeout)

Hi Corey,

That error is mentioned in the SSH.NET forums. You may try replacing the DLL included in the extension for the latest .Net 3.5 release from here. I'll do it when I have some time. In the meanwhile, let us know if this solves the error.

I tried just dropping the newest DLL in and rebuilding it from integration studio, but that gave me "Method not found" errors:

Method not found: 'Void Renci.SshNet.SftpClient.UploadFile(System.IO.Stream, System.String)'.
Stack:
   at OutSystems.NssSFTP.CssSFTP.MssPut(String ssHost, Int32 ssPort, String ssUsername, String ssPassword, String ssPath, Byte[] ssData)
   at ssGemPortalLoader.RssExtensionSFTP.MssPut(HeContext heContext, String inParamHost, Int32 inParamPort, String inParamUsername, String inParamPassword, String inParamPath, Byte[] inParamData)

I then tried opening it in visual studio and doing a "Clean Solution" and "Build Solution", which was successful, but now when I try to publish in in Integration studio I'm getting compile errors:

Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5".
SFTP.cs(38,34): error CS1501: No overload for method 'ListDirectory' takes '1' arguments
SFTP.cs(72,13): error CS1501: No overload for method 'UploadFile' takes '2' arguments
SFTP.cs(89,13): error CS1501: No overload for method 'DownloadFile' takes '2' arguments

Hi Corey,

I just upgraded the Renci.SshNet.dll library and released a new version.

I am using this component but the performance is terribly slow.

some list calls take 120 seconds or so (they do work however) when running from the PAAS environment. 

In filezilla I experience near instant responses from the particular SFTP site.

any suggestions what to do to improve performance?

Rogier M wrote:

I am using this component but the performance is terribly slow.

some list calls take 120 seconds or so (they do work however) when running from the PAAS environment. 

In filezilla I experience near instant responses from the particular SFTP site.

any suggestions what to do to improve performance?

I am not sure what the cause was, but I installed the NUGET from https://www.nuget.org/packages/SSH.NET/

by running the command 'Install-Package SSH.NET''  from visual studio in the package manager console.



After that (and disabling the old DLL)  the SFTP issues were solved and SFTP worked again, withouth the 120 sec delays