Results 1 to 10 of 10

Thread: SFTP creates empty files with sample application.

  1. #1

    Default SFTP creates empty files with sample application.

    Hi,

    I am trying to get up and running with the very latest SFTP impl and I hope you can help me.

    I am trying to run the SFTP inbound receive sample with the latest 2.0.0.RELEASE. The files are created in the specified local directory, however they are empty - they have a 0 byte file size.

    I am running on Windows 7 64-bit, with JDK 1.6.0_22. I am using freeSSHd 1.2.4 as the SFTP server. Previously, I was using the RC2 release, and it ran no problem.

    The context I am using is:

    Code:
    <bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.DefaultSftpSessionFactory">
    	<property name="host" value="${sftp.host}"/>
    	<property name="port" value="22"/>
    	<property name="user" value="${sftp.username}"/>
    	<property name="password" value="${sftp.password}"/>
    </bean>
    	
    <sftp:inbound-channel-adapter id="sftpInboundAdapter"
    		channel="receiveChannel" 
    		session-factory="sftpSessionFactory" 
    		local-directory="file:${sftp.buffer.directory}"
    		remote-directory="."
    		auto-create-local-directory="true"
    		delete-remote-files="true"
    		filename-regex=".*\.csv$">
    	<integration:poller fixed-rate="1000" max-messages-per-poll="1"/>
    </sftp:inbound-channel-adapter>
    	
    <integration:channel id="receiveChannel">
    	<integration:queue/>
    </integration:channel>
    Is there something I am doing wrong?


    Thanks for any help,

    Graham.

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    I am looking into that

  3. #3
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Are you sure that your original files are not empty?
    I just ran the sample that is available with Spring Integration samples (see basic category) http://git.springsource.org/+spring-...ration/samples
    . . . and was able to confirm that the file content is present in the transferred files.
    I can't see any obvious error in your config.

  4. #4

    Default

    I can verify that the files definitely contain data. I checked before running the sample, and also after the sample had run, as despite setting 'delete-remote-files="true"', the original files in SFTP remain.

    Is there anything else I could try that would give you some further insight?

  5. #5
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    I definitely have seen this behavior during our refactoring of FTP and SFTP, but that behavior was on FTP and was fixed anyway during that phase.
    Can you check your logs for Messages that would possibly shed some light?

    The only difference between your configuration and mine is that I am connecting to the localhost. Later on I'll try to setup remote host and transfer from there.

    I'll let you know.

  6. #6

    Default

    Caught it!

    I too am running locally (${sftp.host} resolves to "localhost"), that wasn't it.

    The files I am reading are in the root folder on the SFTP server.

    If I specify the remote directory as:

    Code:
    remote-directory="."
    empty files are created. If I specify the remote directory as:

    Code:
    remote-directory="/"
    then things are fine.

    (Note however, that using 'remote-directory="."' worked fine at RC2.)


    Thanks for your help,

    Graham.

  7. #7
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Graham

    Thanks! I am glad its working, although I am still curious as to why it was behaving like that so i created a JIRA https://jira.springframework.org/browse/INT-1646

    Let me know here or there is you have any more details.

  8. #8
    Join Date
    Sep 2004
    Posts
    9

    Default I have the same problem

    I am using Window 7 64 bit and Java 6u22 as client, SSHD in Cent OS 5.5 server.

    I am sure I have 3 txt files not empty in my home, and I get 3 empty files.

    BTW, if I use FTP, It's OK.

    <bean id="sftpSessionFactory"
    class="org.springframework.integration.sftp.sessio n.DefaultSftpSessionFactory">
    <property name="host" value="192.168.1.106" />
    <property name="port" value="22" />
    <property name="user" value="username" />
    <property name="password" value="mypassword" />
    </bean>

    <int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
    channel="sftpIn"
    session-factory="sftpSessionFactory"
    local-directory="file:output"
    remote-directory="/home/username"
    auto-create-local-directory="true"
    delete-remote-files="false"
    filename-regex=".*\.txt$">
    <intoller fixed-rate="100" default="true" />
    </int-sftp:inbound-channel-adapter>

    <int:channel id="sftpIn">
    </int:channel>

  9. #9
    Join Date
    Sep 2004
    Posts
    9

    Default I resolve it too

    be sure add a slash in the end of remote-directory,

    such as

    remote-directory="/home/username/"

    It's OK now!

  10. #10
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Nice catch! I'll make sure to update the documentation stating that in certain platforms you may need do end the directory definition with slash.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •