"Remotely closed" 当我尝试在 Mule 中使用 HTTPS 发送 REST

"Remotely closed" when I try to send REST with HTTPS in Mule

我有一个简单的 REST HTTPS GET,它的 uri 是这样的:

https://mytest.test:443/nccpointshop/REST/giftcard/giftcards/list/currency/SEK

在浏览器、Postman 等中与 运行 完美配合。使用 Mule 3.8 HTTP 我 select 来自 RAML 生成规范的 uri,设置 uri-param 并且我仍然是出现异常:

DEBUG 2016-06-28 16:38:35,321 [[svc0014_loyalty].http.requester.ODP_Request_Configuration(1) SelectorRunner] com.ning.http.client.providers.grizzly.AsyncHttpClientFilter: REQUEST: HttpRequestPacket (
   method=GET
   url=/nccpointshop/REST/giftcard/giftcards/list/currency/SEK
   query=null
   protocol=HTTP/1.1
   content-length=-1
   headers=[
      Host=correct.host:443
      User-Agent=AHC/1.0
      Connection=keep-alive
      Accept=*/*]
)
DEBUG 2016-06-28 16:38:35,322 [[svc0014_loyalty].http.requester.ODP_Request_Configuration(1) SelectorRunner] org.mule.module.http.internal.HttpMessageLogger: REQUESTER
GET /nccpointshop/REST/giftcard/giftcards/list/currency/SEK HTTP/1.1
Host: correct.host:443
User-Agent: AHC/1.0
Connection: keep-alive
Accept: */*


DEBUG 2016-06-28 16:38:35,498 [[svc0014_loyalty].http.requester.ODP_Request_Configuration.worker(8)] com.ning.http.client.AsyncCompletionHandlerBase: Remotely closed
java.io.IOException: Remotely closed
DEBUG 2016-06-28 16:38:35,520 [[svc0014_loyalty].svc0014_loyalty-httpListenerConfig.worker.02] com.mulesoft.mule.debugger.server.DebuggerMuleNotificationHandlerImpl: MESSAGE_PROCESSOR_POST_INVOKE -> Path /get:\/giftcards:svc0014_loyalty-config/processors/2
DEBUG 2016-06-28 16:38:37,327 [[svc0014_loyalty].Mule.01] com.mulesoft.mule.debugger.server.DebuggerMuleNotificationHandlerImpl: Notification 2001 was received ef4625b0-3d3d-11e6-998f-448500a727fa
ERROR 2016-06-28 16:38:37,329 [[svc0014_loyalty].svc0014_loyalty-httpListenerConfig.worker.02] org.mule.module.apikit.MappingExceptionListener: 
********************************************************************************
Message               : Error sending HTTP request. Message payload is of type: NullPayload
Type                  : org.mule.api.MessagingException
Code                  : MULE_ERROR-29999
Payload               : {NullPayload}
JavaDoc               : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
********************************************************************************
Exception stack is:
1. Remotely closed (java.io.IOException)
2. java.io.IOException: Remotely closed (java.util.concurrent.ExecutionException)
  org.glassfish.grizzly.impl.SafeFutureImpl$Sync:349 (null)
3. java.util.concurrent.ExecutionException: java.io.IOException: Remotely closed (java.io.IOException)
  org.mule.module.http.internal.request.grizzly.GrizzlyHttpClient:245 (null)
4. Error sending HTTP request. Message payload is of type: NullPayload (org.mule.api.MessagingException)
  org.mule.module.http.internal.request.DefaultHttpRequester:287 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
java.io.IOException: Remotely closed

********************************************************************************

我附上了我的配置的图片

Mule HTTP 连接器的特点是它总是从关联的配置中添加主机和端口作为 header: headers=[ 主机=correct.host:443

有些系统不允许这样做,它们不接受添加端口(在我们的例子中,端口是在后端系统中动态分配的)。 所以,这个请求:https://correct.host:443/nccpointshop/REST/giftcard/giftcards/list/currency/SEK

无效,但这个有效: https://correct.host/nccpointshop/REST/giftcard/giftcards/list/currency/SEK

这很难被注意到和捕捉到,因为 Postman 和 Chrome 都会发送正确的请求。我建议使用其他一些工具,如 SoapUI(我用它注意到了)。 但是,有一种方法可以像这样覆盖 header 中 "Host" 的值:

    <http:request config-ref="HTTP_Request_Configuration1" path="/nccpointshop/REST/giftcard/giftcards/list/currency/SEK" method="GET" doc:name="Copy_of_HTTP">
        <http:request-builder>
            <http:header headerName="Host" value="correct.host"/>
        </http:request-builder>
    </http:request>