如何解决400在Apache Camel中将普通HTTP请求发送到HTTPS端口问题?

时间:2018-05-14 22:49:17

标签: apache apache-camel camel-ftp apache-camel-aws

如何解决400普通的HTTP请求被发送到HTTPS端口问题?

from: empValidation
to: myhost:443/EmpValidation/EmpValidationAPIService
 rules.getRules().forEach(x->{
        final LoadBalanceDefinition lb =  from("jetty:http://0.0.0.0:"+rules.getPort()+"/"+x.getFrom()+"??matchOnUriPrefix=true").log(LoggingLevel.DEBUG, "Processing ${id}").log("Incoming Context Request :"+x.getFrom())
        .loadBalance().roundRobin();
        x.getTo().forEach(z->lb.to("http4://"+z+"?bridgeEndpoint=true&throwExceptionOnFailure=true").log("Outgoing mapping urls :"+z)) ;
      });

如果我使用“https4”组件,它正在使用上面的url(empValidation),但它不适用于以下网址。

Url: myhost:9008/emp-web-service/services/addEmp

Error:
 javax.net.ssl.SSLHandshakeException: Remote host closed connection during 
 handshake
          at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
          at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)

我认为如果我们使用默认端口它不起作用,上述场景的解决方案是什么?

1 个答案:

答案 0 :(得分:0)

嗯,这取决于端点是http还是https端点(使用服务器证书来加密客户端和服务器之间的流量)。无论在哪个端口号下发布。

  • 如果端点为https,则需要使用https4://hostname...
  • 之类的URI
  • 如果端点是普通http端点,则需要使用http4://hostname...
  • 之类的URI