You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Jan Bernhardt <jb...@talend.com> on 2012/12/18 11:26:00 UTC
Configure retry limit for failed authentication in REST Client
Hi CXF Users,
is it possible to configure a maximum limit of automatic retries for a CXF REST Client?
I use JAXRSClientFactoryBean to create my service proxy. And when I test a method with wrong credentials, I get 41 retries on my TCP Monitor. So many false tries causes my account to be suspended...
I think it would be best, if CXF only tries once by default and throws an exception directly if authentication fails. Automatic retries could be helpful in some cases but IMHO I don't think this should be default behavior.
WDYT?
Best regards
Jan
Re: Configure retry limit for failed authentication in REST Client
Posted by Sergey Beryozkin <sb...@gmail.com>.
Jan, by the way,
WebClient.getConfig(client).getHttpCoduit().getClient().setMaxRetransmits(1);
will limit the number of retries even if for whatever reasons you get
the retransmission enabled;
Cheers, Sergey
On 18/12/12 16:26, Sergey Beryozkin wrote:
> Hi Jan
> On 18/12/12 14:22, Jan Bernhardt wrote:
>> Hi Sergey,
>>
>>> -----Original Message-----
>>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>>> Sent: Dienstag, 18. Dezember 2012 11:51
>>> To: users@cxf.apache.org
>>> Subject: Re: Configure retry limit for failed authentication in REST
>>> Client
>>>
>>> Hi Jan
>>>
>>> On 18/12/12 10:28, Jan Bernhardt wrote:
>>>> It might be helpful to mention, that I use BASIC-Authentication here.
>>>
>>> It is interesting.
>>> How do you enable basic auth on the client ? In HttpConduit or
>>> directly with
>>> JAXRSClientFactoryBean ?
>>
>> I use setUsername(...) and setPassword(...) within
>> JAXRSClientFactoryBean. I do not configure HttpConduit manually in any
>> way.
>>
>>>
>>> I can see HttpConduit doing processRetransmit() calls every time it gets
>>> 401 (I'm not sure why yet - may be to handle different realm
>>> combintations),
>>> however it checks if the loop can be detected or not, and apparently,
>>> in your
>>> case, no loop can be detected for up to 41 times :-)
>>>
>>> Can you please enable the client side logging so that we can see what is
>>> returned from the server with every 401 ? You can add the logging
>>> feature or
>>> LoggingInInterceptor,
>>
>> I added logging feature to my setup, but for some reasons I currently
>> can't figure out, I don't see any log messages on my console. But here
>> is a sample message copied from my tcp-monitor (they look all the same):
>>
>> Status Code: 401 Unauthorized
>> Content-Length: 1033
>> Content-Type: text/html;charset=utf-8
>> Date: Tue, 18 Dec 2012 14:15:09 GMT
>> Server: Apache-Coyote/1.1
>> WWW-Authenticate: Basic realm="Spring Security Application"
>>
>> The HTTP Body contains an error message HTML encoded.
>>
>
> I'm not sure how to reproduce at the moment...
> HttpConduit in CXF 2.7.1 will not do it by default - only if it's been
> configured to do autoredirects or retransmits or chunking or if the
> authentication supplier requests the stream caching...
>
> We have a test running against Spring Security protected endpoint, it
> uses HttpClient, I updated it to use WebClient locally and can't get
> into HttpConduit#authorizationRetransmit after 401 gets back...
>
> Can you please download CXF source and put few breakpoints in
> HttpConduit, specifically in HttpConduit#authorizationRetransmit ?
>
> Thanks, Sergey
>
>> Best regards.
>> Jan
>>
>>>
>>> Cheers, Sergey
>>>
>>>>
>>>> Regards.
>>>> Jan
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: Jan Bernhardt [mailto:jbernhardt@talend.com]
>>>>> Sent: Dienstag, 18. Dezember 2012 11:26
>>>>> To: users@cxf.apache.org
>>>>> Subject: Configure retry limit for failed authentication in REST
>>>>> Client
>>>>>
>>>>> Hi CXF Users,
>>>>>
>>>>> is it possible to configure a maximum limit of automatic retries for
>>>>> a CXF REST Client?
>>>>>
>>>>> I use JAXRSClientFactoryBean to create my service proxy. And when I
>>>>> test a method with wrong credentials, I get 41 retries on my TCP
>>>>> Monitor. So many false tries causes my account to be suspended...
>>>>>
>>>>> I think it would be best, if CXF only tries once by default and
>>>>> throws an exception directly if authentication fails. Automatic
>>>>> retries could be helpful in some cases but IMHO I don't think this
>>>>> should
>>> be default behavior.
>>>>>
>>>>> WDYT?
>>>>>
>>>>> Best regards
>>>>> Jan
>>
>
>
Re: Configure retry limit for failed authentication in REST Client
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Jan
On 18/12/12 14:22, Jan Bernhardt wrote:
> Hi Sergey,
>
>> -----Original Message-----
>> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
>> Sent: Dienstag, 18. Dezember 2012 11:51
>> To: users@cxf.apache.org
>> Subject: Re: Configure retry limit for failed authentication in REST Client
>>
>> Hi Jan
>>
>> On 18/12/12 10:28, Jan Bernhardt wrote:
>>> It might be helpful to mention, that I use BASIC-Authentication here.
>>
>> It is interesting.
>> How do you enable basic auth on the client ? In HttpConduit or directly with
>> JAXRSClientFactoryBean ?
>
> I use setUsername(...) and setPassword(...) within JAXRSClientFactoryBean. I do not configure HttpConduit manually in any way.
>
>>
>> I can see HttpConduit doing processRetransmit() calls every time it gets
>> 401 (I'm not sure why yet - may be to handle different realm combintations),
>> however it checks if the loop can be detected or not, and apparently, in your
>> case, no loop can be detected for up to 41 times :-)
>>
>> Can you please enable the client side logging so that we can see what is
>> returned from the server with every 401 ? You can add the logging feature or
>> LoggingInInterceptor,
>
> I added logging feature to my setup, but for some reasons I currently can't figure out, I don't see any log messages on my console. But here is a sample message copied from my tcp-monitor (they look all the same):
>
> Status Code: 401 Unauthorized
> Content-Length: 1033
> Content-Type: text/html;charset=utf-8
> Date: Tue, 18 Dec 2012 14:15:09 GMT
> Server: Apache-Coyote/1.1
> WWW-Authenticate: Basic realm="Spring Security Application"
>
> The HTTP Body contains an error message HTML encoded.
>
I'm not sure how to reproduce at the moment...
HttpConduit in CXF 2.7.1 will not do it by default - only if it's been
configured to do autoredirects or retransmits or chunking or if the
authentication supplier requests the stream caching...
We have a test running against Spring Security protected endpoint, it
uses HttpClient, I updated it to use WebClient locally and can't get
into HttpConduit#authorizationRetransmit after 401 gets back...
Can you please download CXF source and put few breakpoints in
HttpConduit, specifically in HttpConduit#authorizationRetransmit ?
Thanks, Sergey
> Best regards.
> Jan
>
>>
>> Cheers, Sergey
>>
>>>
>>> Regards.
>>> Jan
>>>
>>>
>>>> -----Original Message-----
>>>> From: Jan Bernhardt [mailto:jbernhardt@talend.com]
>>>> Sent: Dienstag, 18. Dezember 2012 11:26
>>>> To: users@cxf.apache.org
>>>> Subject: Configure retry limit for failed authentication in REST
>>>> Client
>>>>
>>>> Hi CXF Users,
>>>>
>>>> is it possible to configure a maximum limit of automatic retries for
>>>> a CXF REST Client?
>>>>
>>>> I use JAXRSClientFactoryBean to create my service proxy. And when I
>>>> test a method with wrong credentials, I get 41 retries on my TCP
>>>> Monitor. So many false tries causes my account to be suspended...
>>>>
>>>> I think it would be best, if CXF only tries once by default and
>>>> throws an exception directly if authentication fails. Automatic
>>>> retries could be helpful in some cases but IMHO I don't think this should
>> be default behavior.
>>>>
>>>> WDYT?
>>>>
>>>> Best regards
>>>> Jan
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
RE: Configure retry limit for failed authentication in REST Client
Posted by Jan Bernhardt <jb...@talend.com>.
Hi Sergey,
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Dienstag, 18. Dezember 2012 11:51
> To: users@cxf.apache.org
> Subject: Re: Configure retry limit for failed authentication in REST Client
>
> Hi Jan
>
> On 18/12/12 10:28, Jan Bernhardt wrote:
> > It might be helpful to mention, that I use BASIC-Authentication here.
>
> It is interesting.
> How do you enable basic auth on the client ? In HttpConduit or directly with
> JAXRSClientFactoryBean ?
I use setUsername(...) and setPassword(...) within JAXRSClientFactoryBean. I do not configure HttpConduit manually in any way.
>
> I can see HttpConduit doing processRetransmit() calls every time it gets
> 401 (I'm not sure why yet - may be to handle different realm combintations),
> however it checks if the loop can be detected or not, and apparently, in your
> case, no loop can be detected for up to 41 times :-)
>
> Can you please enable the client side logging so that we can see what is
> returned from the server with every 401 ? You can add the logging feature or
> LoggingInInterceptor,
I added logging feature to my setup, but for some reasons I currently can't figure out, I don't see any log messages on my console. But here is a sample message copied from my tcp-monitor (they look all the same):
Status Code: 401 Unauthorized
Content-Length: 1033
Content-Type: text/html;charset=utf-8
Date: Tue, 18 Dec 2012 14:15:09 GMT
Server: Apache-Coyote/1.1
WWW-Authenticate: Basic realm="Spring Security Application"
The HTTP Body contains an error message HTML encoded.
Best regards.
Jan
>
> Cheers, Sergey
>
> >
> > Regards.
> > Jan
> >
> >
> >> -----Original Message-----
> >> From: Jan Bernhardt [mailto:jbernhardt@talend.com]
> >> Sent: Dienstag, 18. Dezember 2012 11:26
> >> To: users@cxf.apache.org
> >> Subject: Configure retry limit for failed authentication in REST
> >> Client
> >>
> >> Hi CXF Users,
> >>
> >> is it possible to configure a maximum limit of automatic retries for
> >> a CXF REST Client?
> >>
> >> I use JAXRSClientFactoryBean to create my service proxy. And when I
> >> test a method with wrong credentials, I get 41 retries on my TCP
> >> Monitor. So many false tries causes my account to be suspended...
> >>
> >> I think it would be best, if CXF only tries once by default and
> >> throws an exception directly if authentication fails. Automatic
> >> retries could be helpful in some cases but IMHO I don't think this should
> be default behavior.
> >>
> >> WDYT?
> >>
> >> Best regards
> >> Jan
Re: Configure retry limit for failed authentication in REST Client
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Jan
On 18/12/12 10:28, Jan Bernhardt wrote:
> It might be helpful to mention, that I use BASIC-Authentication here.
It is interesting.
How do you enable basic auth on the client ? In HttpConduit or directly
with JAXRSClientFactoryBean ?
I can see HttpConduit doing processRetransmit() calls every time it gets
401 (I'm not sure why yet - may be to handle different realm
combintations), however it checks if the loop can be detected or not,
and apparently, in your case, no loop can be detected for up to 41 times :-)
Can you please enable the client side logging so that we can see what is
returned from the server with every 401 ? You can add the logging
feature or LoggingInInterceptor,
Cheers, Sergey
>
> Regards.
> Jan
>
>
>> -----Original Message-----
>> From: Jan Bernhardt [mailto:jbernhardt@talend.com]
>> Sent: Dienstag, 18. Dezember 2012 11:26
>> To: users@cxf.apache.org
>> Subject: Configure retry limit for failed authentication in REST Client
>>
>> Hi CXF Users,
>>
>> is it possible to configure a maximum limit of automatic retries for a CXF REST
>> Client?
>>
>> I use JAXRSClientFactoryBean to create my service proxy. And when I test a
>> method with wrong credentials, I get 41 retries on my TCP Monitor. So many
>> false tries causes my account to be suspended...
>>
>> I think it would be best, if CXF only tries once by default and throws an
>> exception directly if authentication fails. Automatic retries could be helpful in
>> some cases but IMHO I don't think this should be default behavior.
>>
>> WDYT?
>>
>> Best regards
>> Jan
RE: Configure retry limit for failed authentication in REST Client
Posted by Jan Bernhardt <jb...@talend.com>.
It might be helpful to mention, that I use BASIC-Authentication here.
Regards.
Jan
> -----Original Message-----
> From: Jan Bernhardt [mailto:jbernhardt@talend.com]
> Sent: Dienstag, 18. Dezember 2012 11:26
> To: users@cxf.apache.org
> Subject: Configure retry limit for failed authentication in REST Client
>
> Hi CXF Users,
>
> is it possible to configure a maximum limit of automatic retries for a CXF REST
> Client?
>
> I use JAXRSClientFactoryBean to create my service proxy. And when I test a
> method with wrong credentials, I get 41 retries on my TCP Monitor. So many
> false tries causes my account to be suspended...
>
> I think it would be best, if CXF only tries once by default and throws an
> exception directly if authentication fails. Automatic retries could be helpful in
> some cases but IMHO I don't think this should be default behavior.
>
> WDYT?
>
> Best regards
> Jan