If backend system(REST API) is not closed the connection when they send the response payload as response then how can we close the connection intentionally from mule side(http request) ?
actually we found that backend system is not closing the connection so that mule is throwing 'Remotely Closed' error.
Could anyone suggest how to close the connection in Mule side(HTTP Request connector) after JUST receiving response from backend ?
And below is the HTTP configuration :
<http:request-config name="HTTP_Request_configuration" doc:name="HTTP Request configuration" doc:id="bed9482f-2a7c-4db5-91b5-6410fac08f8e" >
<http:request-connection host="test.com" port="81" /> </http:request-config>
<http:request method="POST" doc:name="Request" doc:id="823ec599-3f8d-4ffa-ba03-72f33f0bc1b8" config-ref="HTTP_Request_configuration" path="/">
</http:request>
Related
I am trying to implement Server Sent Events using the HTTP connector in Mule 4.4.0. I have a flow with an http listener that is accepting SSE client connections and responding to the SSE heartbeat
<flow name="SSE_Subscribe_Flow">
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/events/subscribe" allowedMethods="GET" responseStreamingMode="ALWAYS">
<http:response statusCode="200" >
<http:headers><![CDATA[#[output application/java
---
{
"Content-Type" : "text/event-stream",
"Cache-Control" : "no-cache",
"Connection" : "keep-alive"
}]]]>
</http:headers>
</http:response>
</http:listener>
<logger level="INFO" message="#[message]"/>
</flow>
Is it possible to push messages to the open connection from other flows?
Mule currently doesn't support Server-Sent Events. As an alternative, if you can use Websockets instead note that Mule 4 has a Websockets connector.
I am trying to pass the multiple URI params in the http request as follows:
<http:listener-config name="HTTP_Listener_Configuration"
host="localhost" port="8081" doc:name="HTTP Listener Configuration"
connectionIdleTimeout="40000" />
<http:request-config name="HTTP_Request_Configuration1" protocol="HTTPS" host="" port="443" doc:name="HTTP Request Configuration" connectionIdleTimeout="300000" responseTimeout="50000">
<http:basic-authentication username="user" password="123"/>
</http:request-config>
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration"
path="/paypal" allowedMethods="GET" doc:name="HTTP" />
<set-variable variableName="config" value="#[{'p1':'3054', 'p2':'child/Lines'}]" doc:name="Variable"/>
<http:request config-ref="HTTP_Request_Configuration1" path="/resources/shipment/{p1}/{p2}" method="GET" doc:name="HTTP">
<http:request-builder>
<http:uri-params expression="#[flowVars.config]"/>
</http:request-builder>
</http:request>
</flow>
But this is giving me error as below:
Response code 404 mapped as failure.
ERROR 2019-01-04 18:46:34,526
[[paypaltest].HTTP_Listener_Configuration.worker.01]
org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Response code 404 mapped as failure.
Payload : org.glassfish.grizzly.utils.BufferInputStream#b473ec2
Element : /testFlow/processors/1 # test:test.xml:29 (HTTP)
Element XML : <http:request config-ref="HTTP_Request_Configuration1" path="/resources/shipments/{p1}/{p2}" method="GET" doc:name="HTTP">
<http:request-builder>
<http:uri-params expression="#[flowVars.config]"></http:uri-params>
</http:request-builder>
</http:request>
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.module.http.internal.request.ResponseValidatorException: Response code 404 mapped as failure.
Please let me know if any help can be provide!
It means that the url doesn't exist. Try to hit the url directly in postman before implementing in Mule. Since you wiped out the host="", I'll pretend it's example.com. My guess is that it's having an issue with p2. If you'd like to send the actual string, you'll need to URL encode the "/", which is %2F
So to test hit https://www.example.com/resources/shipments/3054/child%2FLines, with the Basic Auth for Authorization.
Postman: https://www.getpostman.com/apps
The issue i faced was unique to me, i tried this REST api call from SOAPUI and there it gave me the same error i.e. 404 not found so i compared it with POSTMAN request and found that Authorization header was the missing piece for this.
After adding this to http header it worked perfectly.
Please refer
https://docs.mulesoft.com/connectors/http/http-authentication
here are two solutions :
1. Add preemptive="true" in basic authentication configuration
The pre-emptive option passes the user name and password without waiting for a prompt from the server.
Add Authorization in the http:header value ="Basic dXNlcjoxMjM="
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!
I have a web service provider and consumer flows both in same project since I am testing in local. In my consumer flow, I have a HTTP Request connector which is supposed to hit the provider flow but the problem is while debugging it shows timeout to hit the provider flow and if I step over again it hits the provider flow. Also after the provider flow is executed, the control doesnt come back to consumer flow.
Here is HTTP connector config:
<http:request-config name="HTTP_Request_Configuration" host="localhost" port="8081" basePath="/api" connectionIdleTimeout="10000000" doc:name="HTTP Request Configuration"/>
<http:request config-ref="HTTP_Request_Configuration" path="/PatientAdmission" method="POST" doc:name="HTTP"/>
Am I missing something?
Below is the provider HTTP listener config
<http:listener-config name="api-httpListenerConfig" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
<http:listener config-ref="api-httpListenerConfig" path="/api/*" metadata:id="426556ee-3ad8-4231-8c4c-ce3922720e6a" doc:name="HTTP"/>
Could you please try using the below listener configuration and check whether it helps (and let the http request config be the same):
<http:listener-config name="api-httpListenerConfig" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" basePath="api"/>
<http:listener config-ref="api-httpListenerConfig" path="*" doc:name="HTTP"/>
Thanks,
Shijil.R.K
After setting the response codes in the provider HTTP Listener config and consumer HTTP Request config, the response came back to consumer flow.
I've upgraded from Mule 3.3.x to 3.6.x and since the old http endpoint is deprecated in 3.6.x I wanted to migrate to the new HTTP connector.
Here is the original code for calling a webservice and healthcheck
Webservice
<http:outbound-endpoint connector-ref="NoSessionConnector"
address="${testmigrationapp.endpoint.url}"
responseTimeout="${testmigrationapp.endpoint.timeout}" keep-alive="true"
responseTransformer-refs="errorHandler">
<jms:transaction action="ALWAYS_JOIN"/>
Healthcheck
<http:inbound-endpoint exchange-pattern="request-response" address="${testmigrationapp.healthcheck.address}" doc:name="HTTP"/>
How would I implement this using the new HTTP connector?
Thanks
An HTTP outbound endpoint would translate to an HTTP request. You will need to define a request-config specifying the host, port and persistent connections (because of the keep-alive=true). Then you can replace the outbound endpoint with a request element specifying the URL path and the response timeout. For example:
<http:request-config name="persistentRequestConfig" usePersistentConnections="true" host="example.com" port="80" />
<flow name="persistent">
<http:request config-ref="persistentRequestConfig" path="/" responseTimeout="30" />
</flow>
An HTTP inbound endpoint would translate to an HTTP listener. You will need to define a listener-config specifying the host and port. Then you can replace the inbound endpoint for a listener element specifying the URL path. For example:
<http:listener-config name="listenerConfig" host="0.0.0.0" port="8081"/>
<flow name="testFlow">
<http:listener config-ref="listenerConfig" path="/"/>
<echo-component/>
</flow>
For more details you can checkout our docs regarding the migration.