【问题标题】:How to resolve the 400 The plain HTTP request was sent to HTTPS port issue in Apache Camel?如何解决 Apache Camel 中的 400 The plain HTTP request was sent to HTTPS port 问题?
【发布时间】:2018-10-24 16:31:59
【问题描述】:

如何解决 400 The plain HTTP request was sent to HTTPS port 问题?

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 上不起作用。

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)

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

【问题讨论】:

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


    【解决方案1】:

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

    • 如果端点启用了https,则需要使用类似https4://hostname... 的URI
    • 如果端点是普通的http 端点,你需要使用像http4://hostname... 这样的URI

    【讨论】:

    • 感谢您的回复,这里的问题是我通过相同的逻辑路由默认端口(443)和自定义端口(7878)url。请在下面查看详细信息。 1. myhost:443/emp-web-service/services/addEmp 2. myhost:7878/emp-web-service/services/addEmp
    • 使用单个组件,我们应该路由 url。 (https4 --> 适用于 443 个默认 url,http4 --> 适用于自定义端口)
    • 如果你想用同一行代码调用两个端点,这两个端点必须都是 HTTPS 或 HTTP。如果您无法将它们对齐以使用相同的协议,您可以使用 content based routerrecipient list 根据消息头或类似特征切换到正确的端点。
    • 或者您可以尝试使用toD() 使端点动态化。请参阅Dynamic To 下的here。这样,您可以将端点 URI 构造为字符串,将其放在消息头中,然后像这样调用它:.toD("${header.endpointUri}")
    猜你喜欢
    • 2023-04-03
    • 2021-03-23
    • 2019-04-23
    • 2020-08-22
    • 2016-05-19
    • 2022-12-15
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    相关资源
    最近更新 更多