You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mattias Severson <ma...@gmail.com> on 2010/07/05 15:27:00 UTC
Configuration of connection timeout when transmitting files to
remote SFTP server?
Hi,
How do I set the connection timeout when connecting to a remote FTP server?
I attempt to use the ftpClient.connectionTimeout of the
http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html
FTPClient class. It seem to work if the server uses FTP and FTPS, e.g.
ftp://user@host/dir?password=secret&ftpClient.connectionTimeout=30000&disconnect=true&passiveMode=true.
However, when I try to connect to a remote SFTP server I get an exception:
sftp://user@host/dir?password=secret&ftpClient.connectionTimeout=30000&disconnect=true&passiveMode=true
ResolveEndpointFailedException:
[...]
There are 1 parameters that couldn't be set on the endpoint. Check the uri
if the parameters are spelt correctly and that they are properties of the
endpoint. Unknown parameters=[{ftpClient.connectionTimeout=30000}]
I am using a producer template to transmit the files, e.g.
producerTemplate.sendBodyAndHeader(uri, file, Exchange.FILE_NAME,
file.getName());
Camel version: 2.3.0
--
View this message in context: http://camel.465427.n5.nabble.com/Configuration-of-connection-timeout-when-transmitting-files-to-remote-SFTP-server-tp696546p696546.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Configuration of connection timeout when transmitting files to
remote SFTP server?
Posted by Mattias Severson <ma...@gmail.com>.
The Session.connect(int timeout) method eventually calls
Socket.setSoTimeout(int timeout), which implies that the time unit of the
timeout is milliseconds.
I have created an issue:
https://issues.apache.org/activemq/browse/CAMEL-2912
https://issues.apache.org/activemq/browse/CAMEL-2912
/Mattias
--
View this message in context: http://camel.465427.n5.nabble.com/Configuration-of-connection-timeout-when-transmitting-files-to-remote-SFTP-server-tp696546p909735.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Configuration of connection timeout when transmitting files to
remote SFTP server?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You should maybe try to ask / get the attention of the JSCH team.
I think bengt (A camel user) did that when he found an issue with
using private keys and something else.
So they are there.
On Wed, Jul 7, 2010 at 1:13 PM, Mattias Severson <ma...@gmail.com> wrote:
>
> Hmm, maybe I was to hastily to reply and file the issue yesterday. It turned
> out that there is also a connection timeout on the JCH
> http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/Channel.java#Channel.connect%28int%29
> Channel class, which is super class to the
> http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/ChannelSftp.java?av=f
> ChannelSftp (via the
> http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/ChannelSession.java?av=f
> ChannelSession class.
>
> That said, I have not been able to get any timeout what so ever using JSCH.
> When I execute the the code below, I don't get passed the
> "channel.connect(5000);" statement and it does not timeout...
>
>
> File file = new File("toBeSent.txt");
> JSch jsch = new JSch();
>
> File knownHosts = new File("/home/.ssh/known_hosts");
> jsch.setKnownHosts( knownHosts.getAbsolutePath() );
> Session session = jsch.getSession("user", "ftp.company.com");
> {
> session.setPassword("secret");
> session.setPort(2222);
> }
> session.connect(5000);
>
> Channel channel = session.openChannel( "sftp" );
> channel.connect(5000);
> ChannelSftp sftpChannel = (ChannelSftp) channel;
> sftpChannel.put(file.getAbsolutePath(), file.getName());
> sftpChannel.exit();
> session.disconnect();
> --
> View this message in context: http://camel.465427.n5.nabble.com/Configuration-of-connection-timeout-when-transmitting-files-to-remote-SFTP-server-tp696546p1044670.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Configuration of connection timeout when transmitting files to
remote SFTP server?
Posted by Mattias Severson <ma...@gmail.com>.
Hmm, maybe I was to hastily to reply and file the issue yesterday. It turned
out that there is also a connection timeout on the JCH
http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/Channel.java#Channel.connect%28int%29
Channel class, which is super class to the
http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/ChannelSftp.java?av=f
ChannelSftp (via the
http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/ChannelSession.java?av=f
ChannelSession class.
That said, I have not been able to get any timeout what so ever using JSCH.
When I execute the the code below, I don't get passed the
"channel.connect(5000);" statement and it does not timeout...
File file = new File("toBeSent.txt");
JSch jsch = new JSch();
File knownHosts = new File("/home/.ssh/known_hosts");
jsch.setKnownHosts( knownHosts.getAbsolutePath() );
Session session = jsch.getSession("user", "ftp.company.com");
{
session.setPassword("secret");
session.setPort(2222);
}
session.connect(5000);
Channel channel = session.openChannel( "sftp" );
channel.connect(5000);
ChannelSftp sftpChannel = (ChannelSftp) channel;
sftpChannel.put(file.getAbsolutePath(), file.getName());
sftpChannel.exit();
session.disconnect();
--
View this message in context: http://camel.465427.n5.nabble.com/Configuration-of-connection-timeout-when-transmitting-files-to-remote-SFTP-server-tp696546p1044670.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Configuration of connection timeout when transmitting files to
remote SFTP server?
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 6, 2010 at 11:05 AM, Mattias Severson <ma...@gmail.com> wrote:
>
> I may have found a suitable method, how about the
> http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/Session.java#Session.connect%28int%29
> Session.connect(int connectTimeout) method?
>
Great thats the connect timeout, I wonder if its in seconds or millis ?
Then create a ticket in JIRA so we can add a connection timeout option
and have camel-ftp configure this for you.
> I also found the
> http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/Session.java#Session.setTimeout%28int%29
> Session.setTimeout(int timeout) that may correspond to the
> http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html#setDataTimeout%28int%29
> FTPClient.setDataTimeout(int dataTimeout) method.
>
> Unfortunately, I have not found any documentation on JSCH itself, so these
> are my best guesses.
>
> /Mattias
> --
> View this message in context: http://camel.465427.n5.nabble.com/Configuration-of-connection-timeout-when-transmitting-files-to-remote-SFTP-server-tp696546p853217.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Configuration of connection timeout when transmitting files to
remote SFTP server?
Posted by Mattias Severson <ma...@gmail.com>.
I may have found a suitable method, how about the
http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/Session.java#Session.connect%28int%29
Session.connect(int connectTimeout) method?
I also found the
http://grepcode.com/file/repo1.maven.org/maven2/com.jcraft/jsch/0.1.42/com/jcraft/jsch/Session.java#Session.setTimeout%28int%29
Session.setTimeout(int timeout) that may correspond to the
http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html#setDataTimeout%28int%29
FTPClient.setDataTimeout(int dataTimeout) method.
Unfortunately, I have not found any documentation on JSCH itself, so these
are my best guesses.
/Mattias
--
View this message in context: http://camel.465427.n5.nabble.com/Configuration-of-connection-timeout-when-transmitting-files-to-remote-SFTP-server-tp696546p853217.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Configuration of connection timeout when transmitting files to
remote SFTP server?
Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jul 5, 2010 at 3:27 PM, Mattias Severson <ma...@gmail.com> wrote:
>
> Hi,
>
> How do I set the connection timeout when connecting to a remote FTP server?
> I attempt to use the ftpClient.connectionTimeout of the
> http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html
> FTPClient class. It seem to work if the server uses FTP and FTPS, e.g.
> ftp://user@host/dir?password=secret&ftpClient.connectionTimeout=30000&disconnect=true&passiveMode=true.
> However, when I try to connect to a remote SFTP server I get an exception:
>
> sftp://user@host/dir?password=secret&ftpClient.connectionTimeout=30000&disconnect=true&passiveMode=true
> ResolveEndpointFailedException:
> [...]
> There are 1 parameters that couldn't be set on the endpoint. Check the uri
> if the parameters are spelt correctly and that they are properties of the
> endpoint. Unknown parameters=[{ftpClient.connectionTimeout=30000}]
>
> I am using a producer template to transmit the files, e.g.
> producerTemplate.sendBodyAndHeader(uri, file, Exchange.FILE_NAME,
> file.getName());
>
SFTP is based on JCraft JSCH.
http://www.jcraft.com/jsch/
So could you go check their documentation how to set connection
timeout. And report back. Then maybe we can make it easier to set that
for SFTP.
> Camel version: 2.3.0
> --
> View this message in context: http://camel.465427.n5.nabble.com/Configuration-of-connection-timeout-when-transmitting-files-to-remote-SFTP-server-tp696546p696546.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus