Netflix / ribbon

Ribbon is a Inter Process Communication (remote procedure calls) library with built in software load balancers. The primary usage model involves REST calls with various serialization scheme support.
Apache License 2.0
4.58k stars 1.24k forks source link

Annotation Headers incrementing after each request #221

Open schmitch opened 9 years ago

schmitch commented 9 years ago

Hello, currently I use ribbon for some http request, we use the Annotation Proxy method and defined two headers:

                @Header(name = "X-Auth-Token", value = SEARCHConstants.X_AUTH_TOKEN),
                @Header(name = "Content-Type", value = "application/json")

Currently after each requests the headers getting added to the request

First request:

schmitch@SHANGHAI:~$ nc -l 7070
GET /api/oauth/user/info/2/ HTTP/1.1
X-Auth-Token: xxx
Content-Type: application/json
Host: localhost
User-Agent: RxNetty Client

Second request:

schmitch@SHANGHAI:~$ nc -l 7070
GET /api/oauth/user/info/2/ HTTP/1.1
X-Auth-Token: xxx
Content-Type: application/json
X-Auth-Token: xxx
Content-Type: application/json
Host: localhost
User-Agent: RxNetty Client

As you can see, my headers getting doubled, then trippled, then i have four, five, etc.. It looks like the headers getting added and added every request.

My server will add custom headers together so I can't validate the request after the second one, even if I do some parsing I will end up failing badly after some requests (max header size)

Edit: I use ribbon in a playframework client, a Karyon2 RxNetty based Server and a RxNetty based JerseyBlocking Server.

Edit2: Only happens while using the Annotation based client!

esigma5 commented 9 years ago

Hi there, I am having the same problem here. Any updates about a possible fix? @schmitch , did you find a way of fixing the annotation client or just switched to template based client?

EDIT: I noted that the bug only occurs when using multiple instances of the proxy (i.e.: calling Ribbon.from() for every request). On the other hand, if creating the proxy instance once, the problems ceases to exist (didn't find any documentation about that though)

esigma5 commented 9 years ago

Another way of fixing it is to replace com.netflix.ribbon.Ribbon for a custom MyRibbon class, that creates a new DefaultResourceFactory() foreach from() call, and creating foreach new resourcefactory a new MyAnnotationProcessorsProvider (which could be a copy of DefaultAnnotationProcessorsProvider). That way, multiple instances of the same client could be created without this problem. This is useful for also using this MyRibbon class to provide the possibility of creating proxy instances for custom namespaces.

jonathanlarav commented 8 years ago

I have the same issue and for some reason creating a proxy instance just once didn't fixed the issue for me. Wondering if using Feign will also solve the issue or it's an issue with Ribbon itself.