0

I am registering only http scheme for java httpclient 4.1.3

schemeRegistry.register(new Scheme("http", host.getPort(), PlainSocketFactory.getSocketFactory()));

When trying to do call to some http://blabla.bla I am getting the exception below:

...
Caused by: org.apache.http.HttpException: Scheme 'https' not registered.
    at org.apache.http.impl.conn.DefaultHttpRoutePlanner.determineRoute(DefaultHttpRoutePlanner.java:109)
    at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:762)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:381)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882)
    ... 8 more

I believe it's related with environment/endpoint, as it does not work in this particular case only.

I will appreciate any help for this.

  • Your client got a redirect to a more secure (https) url. It seems the server provide http services too but only for redirecting the clients. You should check your link from a browser at active debugging window and preserved/keeped network log, if you see 301 or 302, you can see the (better) URL in that request. – m4gic Aug 30 '18 at 14:51
  • Very thanks, could you provide any real URL that works in the same way? BTW curl posting successfully. – Armen Yeganyan Aug 31 '18 at 10:40
  • curl does not follow the redirects by default (except you give -L), so it should have another reason – m4gic Aug 31 '18 at 12:52
  • Are you sure that your URL starts with HTTP? Could you share the related part of your client's code? – m4gic Aug 31 '18 at 12:55
  • @m4gic Is redirection turned off in Postman and ARC tool as well? – Armen Yeganyan Aug 31 '18 at 13:30
  • Don't know, please check it in the documentation or use a proxy (like TCPTunnelGUI) or a network profiler to check it. – m4gic Aug 31 '18 at 13:34
  • Unfortunately, I see Java HttpClient is also does not redirect automatically: https://stackoverflow.com/questions/5169468/handling-httpclient-redirects – Armen Yeganyan Aug 31 '18 at 13:39
  • Maybe it would be enough just register a https socket factory: schemeRegistry.register( new Scheme("https", 443, SSLSocketFactory.getSystemSocketFactory()) ); – m4gic Aug 31 '18 at 13:44

0 Answers0