Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URISyntaxException with { in a param URL when using Zuul as a proxy #918

Closed
dacofr opened this issue Mar 19, 2016 · 13 comments
Closed

URISyntaxException with { in a param URL when using Zuul as a proxy #918

dacofr opened this issue Mar 19, 2016 · 13 comments

Comments

@dacofr
Copy link

dacofr commented Mar 19, 2016

I've a very simple backend API with a Controller like this

@RestController
@RequestMapping("/echo")
public class MyController {
    @RequestMapping(value = "", method = RequestMethod.GET)
    public String echoParam(
        @RequestParam("param") String param) {
        return param;
    }
}

When i call http://localhost:8080/echo?param={"pgach":["39469"]} all works fine (For some reason, the content of param need to be a JSON string)

Next, i create a simple EurekaServer and connect my backend to Eureka (nothing special)
Then, i create a simple ZuulProxy server with this application.yml

server:
  port: 8585

zuul:
  routes:
    backend_ok:
      path: /backend_ok/**
      url: http://localhost:8080
    backend_ko:
      path: /backend_ko/**
      serviceId: backend

The first case works fine (using url) :
http://localhost:8585/backend_ok/echo?param={"pgach":["39469"]}

But in the second case (using serviceId)
http://localhost:8585/backend_ko/echo?param={"pgach":["39469"]}

I got this Exception

Caused by: javax.ws.rs.core.UriBuilderException: java.net.URISyntaxException: Illegal character in query at index 44: http://localhost:8080/echo?param=%7B"pgach":["39469"]%7D
    at com.sun.jersey.api.uri.UriBuilderImpl.createURI(UriBuilderImpl.java:723) ~[jersey-core-1.19.jar:1.19]
    at com.sun.jersey.api.uri.UriBuilderImpl._build(UriBuilderImpl.java:651) ~[jersey-core-1.19.jar:1.19]
    at com.sun.jersey.api.uri.UriBuilderImpl.build(UriBuilderImpl.java:641) ~[jersey-core-1.19.jar:1.19]
    at com.sun.jersey.api.client.WebResource.<init>(WebResource.java:88) ~[jersey-client-1.19.jar:1.19]
    at com.sun.jersey.api.client.WebResource.queryParam(WebResource.java:443) ~[jersey-client-1.19.jar:1.19]
    at com.netflix.niws.client.http.RestClient.execute(RestClient.java:598) ~[ribbon-httpclient-2.1.0.jar:2.1.0]
    at com.netflix.niws.client.http.RestClient.execute(RestClient.java:527) ~[ribbon-httpclient-2.1.0.jar:2.1.0]
    at com.netflix.niws.client.http.RestClient.execute(RestClient.java:92) ~[ribbon-httpclient-2.1.0.jar:2.1.0]
    at com.netflix.client.AbstractLoadBalancerAwareClient$1.call(AbstractLoadBalancerAwareClient.java:109) ~[ribbon-loadbalancer-2.1.0.jar:2.1.0]
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$3$1.call(LoadBalancerCommand.java:303) ~[ribbon-loadbalancer-2.1.0.jar:2.1.0]
    at com.netflix.loadbalancer.reactive.LoadBalancerCommand$3$1.call(LoadBalancerCommand.java:287) ~[ribbon-loadbalancer-2.1.0.jar:2.1.0]

I'm using SpringBoot 1.3.3 and 1.1.0.M4 of spring-cloud-netflix. I don't know where to search. I tink the problem is with Ribbon, but not sure.

Thanks for your help

@dacofr
Copy link
Author

dacofr commented Mar 19, 2016

Maybe something with commit 41c3640

@dacofr
Copy link
Author

dacofr commented Mar 20, 2016

Sorry @spencergibb but, i've try with 1.1.0-BUILD-SNAPSHOT (18/03/2016 11:58:28),
and i always have the same problem :(

I think the problem appear only with { caracter. Maybe due to usage or URITemplate.

@spencergibb
Copy link
Member

@dacofr does it work urlencoded? %7B%22pgach%22%3A%5B%2239469%22%5D%7D.

@dacofr
Copy link
Author

dacofr commented Mar 21, 2016

No, always the same problem :(

URISyntaxException: Illegal character in query at index 44: http://localhost:8080/echo?param=%7B"pgach":["39469"]%7D

@dacofr
Copy link
Author

dacofr commented Mar 26, 2016

Hi @spencergibb any news about this issue ?
Thanks for your response.

@spencergibb
Copy link
Member

no news.

@arminbalalaie
Copy link

Same problem here. @spencergibb I think it is related to Jersey. See here for more information https://java.net/jira/si/jira.issueviews:issue-html/JERSEY-2525/JERSEY-2525.html. However, I have no idea how we can resolve this.

@dacofr
Copy link
Author

dacofr commented May 1, 2016

Hi, any chance to see this issue resolved ?

Thanks

@spencergibb
Copy link
Member

Try using apache http client rather than the ribbon client.

    @Bean
    public RibbonCommandFactory<?> ribbonCommandFactory(
            final SpringClientFactory clientFactory) {
        return new HttpClientRibbonCommandFactory(clientFactory);
    }

@dacofr
Copy link
Author

dacofr commented May 9, 2016

Thanks, Work's fine with HttpClient.
Any difference (speed, latency, ...) between RibonnClient and HttpClient ?

@spencergibb
Copy link
Member

I don't know. It's really the difference between JerseyClient (which ribbon client uses) and apache httpclient.

@spencergibb
Copy link
Member

That should be documented and possibly auto configured. It should possibly be the default. @dsyer thoughts?

@spencergibb
Copy link
Member

Apache http client is now the default

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants