users@jersey.java.net

[Jersey] Re: Jersey HTTP requests are sent twice, why?

From: Rahul Babbar <rahul.babbar1_at_gmail.com>
Date: Wed, 15 Aug 2012 19:49:28 +0530

Hi,

Can you try to remove SSL, authentication and see if it makes a difference?

I remember I had to do a similar thing once and I made HTTP calls to the
jersey rest web service by using curl, and it showed that I was making two
requests, the first one authenticates and returns the token, and the second
call is with the token and does what it needs to...for better or worse, I
didn't mind that...

Rahul.
On Aug 15, 2012 6:39 PM, "Pulkit Singhal" <pulkitsinghal_at_gmail.com> wrote:

> Thanks Everyone!
>
> @All
> The strangest thing is that if I run the same jersey-client code as a
> standalone java program, there are no problems. But when I try to broker
> the communication between other clients and the webservice by acting as a
> man-in-the-middle via the jersey-servlet ... then this issue pops up. Has
> there ever been any history of jersey-client and jersey-server butting
> heads when running on tomcat, in the past?
>
> @Pavel
>
>> are you sure that requests are actually send twice over network (you can
>> verify this with wireshark/ethereal/tcpdump)? Couldn't it be just somehow
>> misconfigured logging?
>>
>
> The webservice that I'm interacting with is only exposed over a SSL port,
> so I'm in the process of getting its providers to give me the private key
> then I may decrypt & listen in via wireshark but as of now the packets over
> the wire don't tell me much.
>
> @Martynas
>
>> Probably unrelated, but I experienced some double-request behavior
>> when I switched to 1.13:
>> http://java.net/projects/jersey/lists/users/archive/2012-08/message/27
>> Never got a reply though.
>>
>
> Thanks for the link. I'm sorry to hear that you had the same problem and
> its good to know that I'm not alone. Lets hope that we can both get some
> answers on this thread. In the mean time, I'll try to step-through my code
> and see if my constructor is being called twice as well.
>
> @Igor
>
>> The problem was
>> with Netty - based client (AHC-1.65), more specifically in
>> NettyAsyncHttpProvider.
>> remotelyClosed() method.
>>
>
> I'm not using async calls yet (eventually but not yet) and I'm using
> jersey-apache-client4 as the client implementation.
>
> @Igor
>
>> The only
>> situation when I saw something similar with current version of Jersey
>> was due to my bug when I forgot to call response.finish() in my
>> Grizzly HttpHandler at the server side - in this case I saw the (GET)
>> request repeated twice by Jersey client.
>>
>
> Again, I'm not using Grizzly yet, although this too will be a step in the
> right direction for me and I intend to go there eventually. I wonder if the
> finish() method still needs to be called manually in standard resource
> being used by jersey-servlet on tomcat?
>