Description
The SFTPReceiver automatically sends files to another server via SFTP.
In This Article
Receiver Parameters
The following parameters should be defined for the SFTPReceiver. Items with an asterisk(*) are required.
- payloadFilesPath* - Defines the base location of the files to send
- payloadFilesSubDir - Defines the naming convention for subdirectories within the payloadFilesPath
- payloadFilesDescriptor - Defines the name of the descriptor of files to be sent from payloadFilesSubDir
- Example:
- txt - Sends only files whose extension is txt
- xls - Sends only files whose extension is xls
- Example:
- propertiesFilePath* - Defines the location of the configuration properties file
- propertiesSubDir - Defines the subdirectory within the propertiesFilePath where the properties file is located
- propertiesFileName* - Defines the file name of the configuration properties file
- logFileCount* - Defines the number of requests that are executed before logging a message to the console
- threadCount* - Defines the number of requests that may be sent simultaneously.
Configuration (Properties file)
The SFTPReceiver must read from a configuration file that contains information to be able to connect to the SFTP server. The configuration file must contain the properties listed below. Items with an asterisk(*) are required.
- server* - The address of the SFTP server
- username* - The username of SFTP client
- password - The password of the SFTP client (Optional if SFTP server using the ssh key (Example: password=).
- port - The port number where the SFTP server "listens" for client connections. If this is not set, the port will automatically be set to 22 (which is commonly used as the default port for SFTP protocol)
- targetLocation* - The target location in the SFTP server where the files will be transferred. The target location must be ended with the file separator. Example: File Separator in the Linux "/" and in Windows "\\"
- sshKnownHostsLocation - Defines the path to a file having a list of known hosts. The ssh known_hosts file is a file that stores the public key of all of the servers that you have connected using ssh.
- privateKeyPath - There are 2 ways users can connect to the Server. One is by using a username and password. The other is using a private key. If the private key method will be used, then the user needs to provide the location of the private key file. (Example: privateKeyPath=)
- passPhrase - This works with privateKeyPath. This is optional and is only needed when the user should also enter a passPhrase.
- permission - This sets the permissions of the file transferred to the remote location. When the file is transferred but cannot be read and/or written to, the permission can be set with this parameter for the transferred file. (See example located below configuration example).
Configuration File Example
server=192.168.254.7 username=anonymous password=anonymous port=22 targetLocation=/Users/SFTPServer/Downloads/ sshKnownHostsLocation=/Users/SFTPClient/.ssh/known_hosts privateKeyPath=/Users/SFTPClient/.ssh/id_rsa passPhrase=anonymous permission=700
Permission Parameter Example
- 4 = read
- 2 = write
- 1 = execute
- Position 1 = Reader
- Position 2 = User
- Position 3 = Group
Possible Errors
The following errors can occur when using the SFTPReceiver:
UnknownHostKeyException Error
When using the SFTPReceiver, one possible error that occurs is the UnknownHostKeyException. This occurs when Genrocket cannot connect to your SFTP server.
You can do the following commands below:
ssh-keyscan -t rsa <HOST_NAME> >> ~/.ssh/known_hosts ssh-keyscan -t rsa <IP_ADDRESS_OF_HOST_NAME> >> ~/.ssh/known_hosts
Invalid Privatekey Error
ssh-keygen -p -f <yourpathwhereidRSAFileIs> -m pem
Example Test Runs
The following example test runs were performed on a machine with the following specifications:
- MacMini
- Mac OS Mojave
- 16GB RAM
- Intel Core I5 CPU
- 500GB SSD
Test data used in each test run met the following criteria:
- All test files were generated by GenRocket
- One thousand files were generated
- Each file is 3KB in size
For brevity, the example runs below show only the first 100 file transfers.
Test Run With 1 Thread (4m:29s)
Test Run With 2 Threads (2m:55s)
***** Transferred 0 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 0s ***** ..... ***** Transferred 10 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 20 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 30 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 40 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 50 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 60 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 70 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 80 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 90 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s ***** ..... ***** Transferred 100 of 1000 files to SFTP Server using 2 thread/s - Elapsed Time: 1s *****
Test Run With 3 Threads (2m:24s)
***** Transferred 0 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 0s ***** ... ***** Transferred 10 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** ... ***** Transferred 20 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** .... ***** Transferred 30 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** ... ***** Transferred 40 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** ... ***** Transferred 50 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** ... ***** Transferred 60 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** ... ***** Transferred 70 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** ... ***** Transferred 80 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** ... ***** Transferred 90 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s ***** .... ***** Transferred 100 of 1000 files to SFTP Server using 3 thread/s - Elapsed Time: 1s *****
Test Run With 5 Threads (2m:0s)
***** Transferred 0 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 0s ***** .. ***** Transferred 10 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 20 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 30 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 40 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 50 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 60 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 70 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 80 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 90 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s ***** .. ***** Transferred 100 of 1000 files to SFTP Server using 5 thread/s - Elapsed Time: 1s *****
Test Run with 10 Threads (1m:44s)
***** Transferred 0 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 0s ***** . ***** Transferred 10 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** . ***** Transferred 20 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** . ***** Transferred 30 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** . ***** Transferred 40 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** . ***** Transferred 50 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** . ***** Transferred 60 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** . ***** Transferred 70 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** ***** Transferred 80 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** . ***** Transferred 90 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s ***** . ***** Transferred 100 of 1000 files to SFTP Server using 10 thread/s - Elapsed Time: 1s *****