You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Andreas Asmuss <an...@gmail.com> on 2010/07/21 10:41:35 UTC

FTP: Try login once and disconnect if failure.

Hi

I have a route like this:

<route>
	<from
uri="ftp:localhost/inbox/?username=camel&amp;password=camel123&amp;disconnect=true&amp;consumer.delay=60s&amp;maximumReconnectAttempts=0"
/>
			<to uri="file:test_data" />
</route>

In order to prevent user lock out if the wrong password is provided I would
like to try and login only once. With this route Camel makes two connections
at the same time in case the first connection cannot login. Is this
behaviour intended? After some time an exception gets thrown. Preferably I
would like this exception as soon as the client can't login.

(002607) 21-07-2010 10:28:34 - (not logged in) (127.0.0.1)> Connected,
sending welcome message...
(002607) 21-07-2010 10:28:34 - (not logged in) (127.0.0.1)> 220-FileZilla
Server version 0.9.34 beta
(002607) 21-07-2010 10:28:34 - (not logged in) (127.0.0.1)> 220-written by
Tim Kosse (Tim.Kosse@gmx.de)
(002607) 21-07-2010 10:28:34 - (not logged in) (127.0.0.1)> 220 Please visit
http://sourceforge.net/projects/filezilla/
(002607) 21-07-2010 10:28:39 - (not logged in) (127.0.0.1)> USER camel
(002607) 21-07-2010 10:28:39 - (not logged in) (127.0.0.1)> 331 Password
required for camel
(002607) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> PASS *******
(002607) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> 530 Login or
password incorrect!
(002608) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> Connected,
sending welcome message...
(002608) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> 220-FileZilla
Server version 0.9.34 beta
(002608) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> 220-written by
Tim Kosse (Tim.Kosse@gmx.de)
(002608) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> 220 Please visit
http://sourceforge.net/projects/filezilla/
(002608) 21-07-2010 10:28:51 - (not logged in) (127.0.0.1)> USER camel
(002608) 21-07-2010 10:28:51 - (not logged in) (127.0.0.1)> 331 Password
required for camel
(002608) 21-07-2010 10:28:57 - (not logged in) (127.0.0.1)> PASS *******
(002608) 21-07-2010 10:28:57 - (not logged in) (127.0.0.1)> 530 Login or
password incorrect!
(002608) 21-07-2010 10:29:15 - (not logged in) (127.0.0.1)> QUIT
(002608) 21-07-2010 10:29:15 - (not logged in) (127.0.0.1)> 221 Goodbye
(002608) 21-07-2010 10:29:15 - (not logged in) (127.0.0.1)> disconnected.
(002607) 21-07-2010 10:29:22 - (not logged in) (127.0.0.1)> disconnected.

WARNING: Trying to recover by disconnecting from remote server forcing a
re-connect at next poll: ftp://camel@localhost:21
21-07-2010 10:29:15 org.apache.camel.impl.DefaultPollingConsumerPollStrategy
rollback
WARNING: Consumer
Consumer[ftp://localhost/inbox/?consumer.delay=60s&disconnect=true&maximumReconnectAttempts=0&password=camel12&timeout=5000&username=camel]
could not poll endpoint:
ftp://localhost/inbox/?consumer.delay=60s&disconnect=true&maximumReconnectAttempts=0&password=camel12&timeout=5000&username=camel
caused by: File operation failed: 530 Login or password incorrect!
. Code: 530
org.apache.camel.component.file.GenericFileOperationFailedException: File
operation failed: 530 Login or password incorrect!
. Code: 530
	at
org.apache.camel.component.file.remote.FtpOperations.connect(FtpOperations.java:161)
-- 
View this message in context: http://camel.465427.n5.nabble.com/FTP-Try-login-once-and-disconnect-if-failure-tp1692660p1692660.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FTP: Try login once and disconnect if failure.

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jul 21, 2010 at 4:28 PM, Andreas Asmuss <an...@gmail.com> wrote:
>
> Hi
>
> I tried stepping through the process of connecting with a bad password, and
> I can see that it is intentional to try a few times with a new FTPClient
> instance to connect before giving up - as I'm trying to limit the
> loginattempts to 1 and then abort this is a little annoying :)
>
> When using the consumer to log in there will always be two login attempts
> before an exception is thrown back to the caller.
>
> When using the producer there will always be 3 attempts before the exception
> is thrown back to the caller.
>

Yeah we will revisit this in 2.5. That code with re-connect attempts
was to fix the issue about self healing a connection.
This was improved in 2.4, so I do not think we need the 3-reconnect by
default now.


> I don't know if this use case us too unusual or if an option to throw only
> attempt login once before throwing the exception could be introduced?
> --
> View this message in context: http://camel.465427.n5.nabble.com/FTP-Try-login-once-and-disconnect-if-failure-tp1692660p1723766.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: FTP: Try login once and disconnect if failure.

Posted by Andreas Asmuss <an...@gmail.com>.
Hi

I tried stepping through the process of connecting with a bad password, and
I can see that it is intentional to try a few times with a new FTPClient
instance to connect before giving up - as I'm trying to limit the
loginattempts to 1 and then abort this is a little annoying :) 

When using the consumer to log in there will always be two login attempts
before an exception is thrown back to the caller.

When using the producer there will always be 3 attempts before the exception
is thrown back to the caller.

I don't know if this use case us too unusual or if an option to throw only
attempt login once before throwing the exception could be introduced?
-- 
View this message in context: http://camel.465427.n5.nabble.com/FTP-Try-login-once-and-disconnect-if-failure-tp1692660p1723766.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FTP: Try login once and disconnect if failure.

Posted by Andreas Asmuss <an...@gmail.com>.
After consulting Camel in Action I found that
org.apache.camel.PollingConsumerPollStrategy is the answer to errorhandling
before an Exchange is create in this case :)

The problem with multiple connections when login fails still stands though.
-- 
View this message in context: http://camel.465427.n5.nabble.com/FTP-Try-login-once-and-disconnect-if-failure-tp1692660p1714922.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FTP: Try login once and disconnect if failure.

Posted by Andreas Asmuss <an...@gmail.com>.
Another thing I don't understand: How can I catch the exception thrown from
the FtpComponent. <onException> doesn't work which I assume is because
errorhandling doesn't work until a message has entered the route.
-- 
View this message in context: http://camel.465427.n5.nabble.com/FTP-Try-login-once-and-disconnect-if-failure-tp1692660p1710585.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FTP: Try login once and disconnect if failure.

Posted by Andreas Asmuss <an...@gmail.com>.
Actually this issue is also present when not having disconnect=true in the
uri.
-- 
View this message in context: http://camel.465427.n5.nabble.com/FTP-Try-login-once-and-disconnect-if-failure-tp1692660p1701993.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FTP: Try login once and disconnect if failure.

Posted by Andreas Asmuss <an...@gmail.com>.
Hi

Jira ticket: https://issues.apache.org/activemq/browse/CAMEL-2979

Is it possible to make Camel drop the connection some other way? 
I would like to:

connect
poll
fetch files (if any)
disconnect

I tried some of the timeout options but they don't have any effect.

On a related note: I would like to actually close the entire application if
the login fails. I'm running it as a standalone jar with a main-method that
loads a camel Main. Could I propagate an exception from the route and to the
main-method to do a shutdown on the camelContext in Main?
-- 
View this message in context: http://camel.465427.n5.nabble.com/FTP-Try-login-once-and-disconnect-if-failure-tp1692660p1695380.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: FTP: Try login once and disconnect if failure.

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Ah that is because you have an explicit disconnect configured with
disconnect=true.
Could you create a JIRA ticket.


On Wed, Jul 21, 2010 at 10:41 AM, Andreas Asmuss
<an...@gmail.com> wrote:
>
> Hi
>
> I have a route like this:
>
> <route>
>        <from
> uri="ftp:localhost/inbox/?username=camel&amp;password=camel123&amp;disconnect=true&amp;consumer.delay=60s&amp;maximumReconnectAttempts=0"
> />
>                        <to uri="file:test_data" />
> </route>
>
> In order to prevent user lock out if the wrong password is provided I would
> like to try and login only once. With this route Camel makes two connections
> at the same time in case the first connection cannot login. Is this
> behaviour intended? After some time an exception gets thrown. Preferably I
> would like this exception as soon as the client can't login.
>
> (002607) 21-07-2010 10:28:34 - (not logged in) (127.0.0.1)> Connected,
> sending welcome message...
> (002607) 21-07-2010 10:28:34 - (not logged in) (127.0.0.1)> 220-FileZilla
> Server version 0.9.34 beta
> (002607) 21-07-2010 10:28:34 - (not logged in) (127.0.0.1)> 220-written by
> Tim Kosse (Tim.Kosse@gmx.de)
> (002607) 21-07-2010 10:28:34 - (not logged in) (127.0.0.1)> 220 Please visit
> http://sourceforge.net/projects/filezilla/
> (002607) 21-07-2010 10:28:39 - (not logged in) (127.0.0.1)> USER camel
> (002607) 21-07-2010 10:28:39 - (not logged in) (127.0.0.1)> 331 Password
> required for camel
> (002607) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> PASS *******
> (002607) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> 530 Login or
> password incorrect!
> (002608) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> Connected,
> sending welcome message...
> (002608) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> 220-FileZilla
> Server version 0.9.34 beta
> (002608) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> 220-written by
> Tim Kosse (Tim.Kosse@gmx.de)
> (002608) 21-07-2010 10:28:45 - (not logged in) (127.0.0.1)> 220 Please visit
> http://sourceforge.net/projects/filezilla/
> (002608) 21-07-2010 10:28:51 - (not logged in) (127.0.0.1)> USER camel
> (002608) 21-07-2010 10:28:51 - (not logged in) (127.0.0.1)> 331 Password
> required for camel
> (002608) 21-07-2010 10:28:57 - (not logged in) (127.0.0.1)> PASS *******
> (002608) 21-07-2010 10:28:57 - (not logged in) (127.0.0.1)> 530 Login or
> password incorrect!
> (002608) 21-07-2010 10:29:15 - (not logged in) (127.0.0.1)> QUIT
> (002608) 21-07-2010 10:29:15 - (not logged in) (127.0.0.1)> 221 Goodbye
> (002608) 21-07-2010 10:29:15 - (not logged in) (127.0.0.1)> disconnected.
> (002607) 21-07-2010 10:29:22 - (not logged in) (127.0.0.1)> disconnected.
>
> WARNING: Trying to recover by disconnecting from remote server forcing a
> re-connect at next poll: ftp://camel@localhost:21
> 21-07-2010 10:29:15 org.apache.camel.impl.DefaultPollingConsumerPollStrategy
> rollback
> WARNING: Consumer
> Consumer[ftp://localhost/inbox/?consumer.delay=60s&disconnect=true&maximumReconnectAttempts=0&password=camel12&timeout=5000&username=camel]
> could not poll endpoint:
> ftp://localhost/inbox/?consumer.delay=60s&disconnect=true&maximumReconnectAttempts=0&password=camel12&timeout=5000&username=camel
> caused by: File operation failed: 530 Login or password incorrect!
> . Code: 530
> org.apache.camel.component.file.GenericFileOperationFailedException: File
> operation failed: 530 Login or password incorrect!
> . Code: 530
>        at
> org.apache.camel.component.file.remote.FtpOperations.connect(FtpOperations.java:161)
> --
> View this message in context: http://camel.465427.n5.nabble.com/FTP-Try-login-once-and-disconnect-if-failure-tp1692660p1692660.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