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

I have a simple REST HTTPS GET, the uri of it is like that:
https://mytest.test:443/nccpointshop/REST/giftcard/giftcards/list/currency/SEK
which works perfectly to run in a browser, Postman, etc. With Mule 3.8 HTTP I select the uri from the RAML generataed specification, set uri-param and still I am getting an exception :
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
********************************************************************************
I am attaching a picture of how my configuration looks like

The thing with Mule HTTP connector is that it adds host and port from the associated configuration always as a header:
headers=[
Host=correct.host:443
Some systems do not allow that, they do not accept adding the port (in our case the port is dynamically allocated in the backend system).
So, this request: https://correct.host:443/nccpointshop/REST/giftcard/giftcards/list/currency/SEK
is invalid, but this one is valid:
https://correct.host/nccpointshop/REST/giftcard/giftcards/list/currency/SEK
This is hard to notice and catch, as Postman and Chrome will both send correct requests. I recommend using some other tool like SoapUI (I noticed it with it).
However, there is a way to overwrite the value for the "Host" in the headers like this:
<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>

Related

Mulesoft NetSuite Connector throw java.lang.NullPointerException: charsetName Error

I am getting this error in my mulesoft application while making a search call to NetSuite connector (v11.5.12).
org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://client.internal.soap.mule.org/}ProxyService#{http://client.internal.soap.mule.org/}invoke has thrown exception, unwinding now
java.lang.NullPointerException: charsetName
This error has suddenly started to come in the production environment. I am not able to replicate the same in lower environment.
Mule Application is deployment on Anypoint CloudHub with Mule Runtime version 4.4.0
NetSuite connector version v11.5.12
No recent changes deployed to production, existing application started to throw this error while searching
I enabled NetSuite Debug Logger and below are the logs it generated.
DEBUG 2023-02-15 13:50:53,636 [[finance-bulk-api].NetSuite_Config.04 SelectorRunner] [processor: netsuite-advance-search/processors/1/processors/0/processors/0; event: a91c2ba0-ad09-11ed-b6b5-88665a243a09] org.mule.service.http.impl.service.HttpMessageLogger.NetSuite_Config: REQUESTER
POST /services/NetSuitePort_2021_1 HTTP/1.1
SOAPAction: search
Host: 1111.suitetalk.api.netsuite.com
User-Agent: AHC/1.0
Connection: keep-alive
Accept: */*
Content-Type: text/xml
Transfer-Encoding: chunked
c57
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><preferences xmlns="urn:messages_2021_1.platform.webservices.netsuite.com"><warningAsError>false</warningAsError><disableMandatoryCustomFieldValidation>false</disableMandatoryCustomFieldValidation><disableSystemNotesForCustomFields>false</disableSystemNotesForCustomFields><ignoreReadOnlyFields>false</ignoreReadOnlyFields><runServerSuiteScriptAndTriggerWorkflows>false</runServerSuiteScriptAndTriggerWorkflows></preferences><tokenPassport xmlns="urn:messages_2021_1.platform.webservices.netsuite.com"><account xmlns="urn:core_2021_1.platform.webservices.netsuite.com">****</account><consumerKey xmlns="urn:core_2021_1.platform.webservices.netsuite.com">*****</consumerKey><token xmlns="urn:core_2021_1.platform.webservices.netsuite.com">****</token><nonce xmlns="urn:core_2021_1.platform.webservices.netsuite.com">****</nonce><timestamp xmlns="urn:core_2021_1.platform.webservices.netsuite.com">****</timestamp><signature xmlns="urn:core_2021_1.platform.webservices.netsuite.com" algorithm="HMAC_SHA256">fhpl/bxKP/cfuAYhSQ/MULWdkfjfnkfkUlMbWguVr9a6MaXS5fhRUDJVIdjdonddU=</signature></tokenPassport><searchPreferences xmlns="urn:messages_2021_1.platform.webservices.netsuite.com"><bodyFieldsOnly>false</bodyFieldsOnly><returnSearchColumns>true</returnSearchColumns><pageSize>10</pageSize></searchPreferences></soap:Header><soap:Body><ns0:search xmlns:ns0="urn:messages_2021_1.platform.webservices.netsuite.com">
<ns0:searchRecord xmlns:ns01="urn:sales_2021_1.transactions.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns01:TransactionSearchAdvanced">
<ns01:criteria xmlns:ns01="urn:sales_2021_1.transactions.webservices.netsuite.com">
<ns01:basic>
<ns02:lastModifiedDate xmlns:ns02="urn:common_2021_1.platform.webservices.netsuite.com" operator="within">
<ns03:searchValue xmlns:ns03="urn:core_2021_1.platform.webservices.netsuite.com">2023-02-13T22:00:49</ns03:searchValue>
<ns03:searchValue2 xmlns:ns03="urn:core_2021_1.platform.webservices.netsuite.com">2023-02-14T22:00:49</ns03:searchValue2>
</ns02:lastModifiedDate>
<ns02:recordType xmlns:ns02="urn:common_2021_1.platform.webservices.netsuite.com" operator="is">
<ns03:searchValue xmlns:ns03="urn:core_2021_1.platform.webservices.netsuite.com">Invoice</ns03:searchValue>
</ns02:recordType>
</ns01:basic>
</ns01:criteria>
<ns01:columns xmlns:ns01="urn:sales_2021_1.transactions.webservices.netsuite.com">
<ns01:basic>
<ns02:amountRemaining xmlns:ns02="urn:common_2021_1.platform.webservices.netsuite.com"/>
<ns02:internalId xmlns:ns02="urn:common_2021_1.platform.webservices.netsuite.com">
<ns03:searchValue xmlns:ns03="urn:core_2021_1.platform.webservices.netsuite.com" internalId="null"/>
</ns02:internalId>
</ns01:basic>
</ns01:columns>
</ns0:searchRecord>
</ns0:search></soap:Body></soap:Envelope>
DEBUG 2023-02-15 13:50:53,636 [[biz-prc-ent-finance-bulk-api].NetSuite_Config.04 SelectorRunner] [processor: netsuite-advance-search/processors/1/processors/0/processors/0; event: a91c2ba0-ad09-11ed-b6b5-88665a243a09] org.mule.service.http.impl.service.HttpMessageLogger.NetSuite_Config: REQUESTER
0
DEBUG 2023-02-15 13:50:58,153 [[finance-bulk-api].NetSuite_Config.04 SelectorRunner] [processor: netsuite-advance-search/processors/1/processors/0/processors/0; event: a91c2ba0-ad09-11ed-b6b5-88665a243a09] org.mule.service.http.impl.service.HttpMessageLogger.NetSuite_Config: REQUESTER
HTTP/1.1 504 Gateway Time-out
Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 176
Expires: Wed, 15 Feb 2023 08:20:58 GMT
X-Reference-Error: 97.27697c68.1676449258.23382b2c
Date: Wed, 15 Feb 2023 08:20:58 GMT
Connection: close
Akamai-GRN: 0.df523617.1676449254.1f240dc8
<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>
An error occurred while processing your request.<p>
Reference &#3
5;97.27697c68.1676449258.23382b2c
</BODY></HTML>
WARN 2023-02-15 13:50:58,155 [[MuleRuntime].uber.02: [finance-bulk-api].netsuite-to-salesforce-sync-shcedular-flow.BLOCKING #32c6a070] [processor: netsuite-advance-search/processors/1/processors/0/processors/0; event: a91c2ba0-ad09-11ed-b6b5-88665a243a09] org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://client.internal.soap.mule.org/}ProxyService#{http://client.internal.soap.mule.org/}invoke has thrown exception, unwinding now
java.lang.NullPointerException: charsetName
at java.io.InputStreamReader.<init>(InputStreamReader.java:99) ~[?:1.8.0_312]
Clearly the error is a timeout on the Netsuite infrastructure:
HTTP/1.1 504 Gateway Time-out
It it not possible to know the cause of the error from the data provided. It could be a Netsuite issue, a configuration issue (wrong connection address?), or simply that the operation takes too long to complete (data issue, which may vary between environments).
It would be recommended to upgrade to the latest Mule Netsuite connector release and test again. There have several fixes and improvements since the version you are using was released, including security fixes and error messages improvements. Even if it doesn't solve the issue you are experiencing you would be better covered against those issues.

Mulesoft connection timeout issue

I'm getting a Connect timeout exception when I try to run a simple mule flow:
Message : Error sending HTTP request. Payload
: {NullPayload} Payload Type : org.mule.transport.NullPayload
Element : /getunitedflightsFlow/processors/0 #
getunitedflights:getunitedflights.xml:15 (Get Flights Requests)
Element XML :
Root Exception stack trace: java.net.ConnectException: Connect timeout
at
org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectCompletionHandler.cancelled(SingleEndpointPool.java:1284)
at
org.glassfish.grizzly.impl.SafeFutureImpl.notifyCompletionHandlers(SafeFutureImpl.java:185)
at
org.glassfish.grizzly.impl.SafeFutureImpl.done(SafeFutureImpl.java:277)
at
org.glassfish.grizzly.impl.SafeFutureImpl$Sync.innerCancel(SafeFutureImpl.java:389)
at
org.glassfish.grizzly.impl.SafeFutureImpl.cancel(SafeFutureImpl.java:247)
at
org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1352)
at
org.glassfish.grizzly.connectionpool.SingleEndpointPool$ConnectTimeoutWorker.doWork(SingleEndpointPool.java:1344)
at
org.glassfish.grizzly.utils.DelayedExecutor$DelayedRunnable.run(DelayedExecutor.java:158)
at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:748)
Here is the Mule flow:
<flow name="getunitedflightsFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/home" doc:name="HTTP"/>
<http:request config-ref="HTTP_Request_Configuration" path="/essentials/united/flights" method="GET" doc:name="Get Flights Requests"/>
</flow>
I did some googling and it looks like a proxy/firewall issue, I tried adding the proxy settings under preferences and all Native/Direct/Manual options won't work. I also added the following properties/args:
-XX:PermSize=128M -XX:MaxPermSize=256M -Dhttps.proxyHost=proxy.xxxx.com -Dhttps.proxyPort=8080 -Dhttps.proxyUsername=myfirst.mylast -Dhttps.proxyPassword=xxxxxxxxx
it doesn't work, also tried changing the proxy settings in the Http request connector itself but this doesn't work either.
Does anyone know what's going on here,
your help is appreciated!

Post file from mule to API

I am submitting a file to a third party api. I can make the request using postman, and the third party accepts the response:
my mule flow starts with a http request, and I am able to send the file in the message.inboundAttachments dictionary, but I am not sure how to build the request to the third party in a mule flow. When I try to set the message.InboundAttachment['Contract'] item into the payload, I just get a generic message:
"Error sending HTTP request. Message payload is of type: DataHandler"
I am not sure what is failing.
update below is a screenshot of the part of the flow I attempted with using the attachment component:
the attachment component looks like the following:
<set-attachment attachmentName="#[message.inboundAttachments.Contract.dataSource.part.fileName]" value="#[message.inboundAttachments['Contract'].getInputStream()]" contentType="multipart/form-data" doc:name="Attaching Contract"/>
I am getting the following error though when I attempt to send this:
> ERROR 2016-05-03 11:26:45,597
> [[pan.internal.api].api-httpListenerConfig.worker.01]
> org.mule.exception.DefaultMessagingExceptionStrategy:
> ******************************************************************************** Message : Error sending HTTP request. Message payload is
> of type: NullPayload Type :
> org.mule.api.MessagingException Code : MULE_ERROR--2
> JavaDoc :
> http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html
> Payload : {NullPayload}
> ******************************************************************************** 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
>
> ********************************************************************************
I have also tried to clear the Attachment Content Type field, but it seems to be required, and raises an error as well. Any ideas?
You don't need to add the attachment as payload for the request, what you need to do is move it from InboundAttachments to OutboundAttachments. The requester component will detect there are OutboundAttachments present and perform a multipart/form-data request with them.
HTH
update
the copy-attachments will correctly set the content-length and pass through the contents, rather than setting the attachment:
<copy-attachments attachmentName="Contract" doc:name="Attaching Contract" />

mule ce 3.7.0 Exception when sending http-request - Timeout exceeded (java.util.concurrent.TimeoutException)

I'm trying to send a http request from my jax-ws client to my own jaw-ws service. I've generated classes from wsdl and sending an ArrayList of objects with 60 items in it. But i'm getting exception.
Exception stack is:
1. Timeout exceeded (java.util.concurrent.TimeoutException)
com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider:426 (null)
2. Error sending HTTP request. Message payload is of type: byte[] (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.util.concurrent.TimeoutException: Timeout exceeded
at com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider.timeout(GrizzlyAsyncHttpProvider.java:426)
at com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider$3.onTimeout(GrizzlyAsyncHttpProvider.java:274)
at org.glassfish.grizzly.utils.IdleTimeoutFilter$DefaultWorker.doWork(IdleTimeoutFilter.java:398)
at org.glassfish.grizzly.utils.IdleTimeoutFilter$DefaultWorker.doWork(IdleTimeoutFilter.java:377)
at org.glassfish.grizzly.utils.DelayedExecutor$DelayedRunnable.run(DelayedExecutor.java:158)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Anyone has a solution for this?
I had the same problem and I solved using the parameter responseTimeout in the HTTP-Request configuration:
<http:request-config responseTimeout="30000" {more parameters...} />
Set the value (in ms) to the time that you think best.

Carriage return "%0A" in ActiveMQ/Camel message raise an exception

I'm working on an API for my website, using ActiveMQ and Camel in order iPhones to connect via Stomp protocol.
The body of the message is a JSON with different parameters that I will then pass to a PHP web app, for example Post data, and so on.
We got a form on the iphone, with a "textarea". If I submit a simple line, without carriage returns, ActiveMQ and Camel handle it, pass it to my PHP app which save it in DB, and everything is fine.
But when there is a carriage return in the textarea value, encoded as "%0A", ActiveMQ raises an exception, and the PHP app is not called.
In my apache error log, I only have this line :
[Mon May 14 16:08:54 2012] [error] [client 127.0.0.1] An URL must be provided
In my ActiveMQ log I have (I havent pasted all of it, only the first raise) :
2012-05-14 16:42:22,038 | DEBUG | Caused by: [org.apache.camel.RuntimeCamelException - org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http//localapi:80/api_dev.php/dispatcher with statusCode: 500] | org.apache.camel.component.jms.EndpointMessageListener | Camel (camel) thread #0 - JmsConsumer[query]
org.apache.camel.RuntimeCamelException: org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http//localapi:80/api_dev.php/dispatcher with statusCode: 500
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1139)
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:115)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:560)
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1056)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1048)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:947)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: org.apache.camel.component.http.HttpOperationFailedException: HTTP operation failed invoking http//localapi:80/api_dev.php/dispatcher with statusCode: 500
at org.apache.camel.component.jetty.DefaultJettyHttpBinding.populateHttpOperationFailedException(DefaultJettyHttpBinding.java:143)
at org.apache.camel.component.jetty.DefaultJettyHttpBinding.populateResponse(DefaultJettyHttpBinding.java:61)
at org.apache.camel.component.jetty.JettyContentExchange.doTaskCompleted(JettyContentExchange.java:149)
at org.apache.camel.component.jetty.JettyContentExchange.onResponseComplete(JettyContentExchange.java:86)
at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:887)
at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:258)
at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:580)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:314)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:211)
at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:254)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:506)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
... 1 more
The message's body looks like :
Message:
body={
"session_id":"XXXX",
"method":"post",
"params":{
"post":{
"form_name":{
"field_name":"foo%0Abar"
}
}
},
"url":"/my_object/update",
"query_id":"XXX"
}
My ActiveMQ conf is made with Spring, as I'm not too much (at all) into Java
Thank you for any clue