Created 06-03-2020 02:34 AM
We want to configure listenhttp processor that listen our web service. question is what are the configuration in http listener processor in nifi such that when we will make curl post request this ListenHttp processor will catch the update. basically i didn't understand what i have to put in Base path (is it i have to put nifi address i.e http://localhost:8080/contentListener or our web app service URL???) what is contentListener. And is it i have to put our web app port number in listening port? in the request command what i have to put in url part
curl --request POST 'http://(here i have to used the nifi url)' -H 'Authorization: Key demo-key
i know this is very basic question but i'm just using this don't know any thing about nifi and curl command .....thanks in advance
Created 06-03-2020 09:20 AM
Hi @renuu ,
You can use'HandleHttpRequest' to listen for incoming GET/POST request on specific port and respond back using 'HandleHttpResponse' processor.
Add one Http Context Map controller service and use the same in both processor to map request to response, thats it.
Take a look at the below sample configurations.
This HandleHTTPRequest listens for http requests on port 8888 & specifi path i.e /curlRequest.
'Allowed path' is optional, if you just want listen for any request then you ca remove that value.
HandleHTTPResponse responds to client with 201 response code and any content which is flowfile content.
Instead of curl command I have invoked above listener with another NiFi processor (which you can consider as client)
InvokeHttp processor with target end point as above HandleHTTPRequest host & port.
I am using host as localhost as I am invoking form Nifi (local) only.
For curl command form outside, you need to use your nifi host name instead of 'localhost'.
So that would be 'http://<hostname>':8888/curlRequest
All together -
Please ACCEPT the solution if it helps/resolves your problem.
Thanks
Mahendra
Created 06-04-2020 01:55 AM
Hi @renuu
ListenHTTP also works same way -
Find below sample configuration and how to invoke using curl.
ListenHTTP listens on a specific port (in my case 8889) and a base path ('/curlRequestListener')
Using below curl command from terminal you can post data -
curl -d 'my request data' http://<nifihostname>:8889/curlRequestListener
'my request data' is the sample data which I am posting to the ListenHTTP processor and same is received in processors and queued as flowfile.
Received request Flowfile content -
Created 06-03-2020 09:20 AM
Hi @renuu ,
You can use'HandleHttpRequest' to listen for incoming GET/POST request on specific port and respond back using 'HandleHttpResponse' processor.
Add one Http Context Map controller service and use the same in both processor to map request to response, thats it.
Take a look at the below sample configurations.
This HandleHTTPRequest listens for http requests on port 8888 & specifi path i.e /curlRequest.
'Allowed path' is optional, if you just want listen for any request then you ca remove that value.
HandleHTTPResponse responds to client with 201 response code and any content which is flowfile content.
Instead of curl command I have invoked above listener with another NiFi processor (which you can consider as client)
InvokeHttp processor with target end point as above HandleHTTPRequest host & port.
I am using host as localhost as I am invoking form Nifi (local) only.
For curl command form outside, you need to use your nifi host name instead of 'localhost'.
So that would be 'http://<hostname>':8888/curlRequest
All together -
Please ACCEPT the solution if it helps/resolves your problem.
Thanks
Mahendra
Created 06-03-2020 11:51 PM
@hegdemahendra thanks for solution...but I really want to know listenhttp processor configuration....and your explanation method is awesome with flow and configuration. Thank alot ....
Created 06-04-2020 01:55 AM
Hi @renuu
ListenHTTP also works same way -
Find below sample configuration and how to invoke using curl.
ListenHTTP listens on a specific port (in my case 8889) and a base path ('/curlRequestListener')
Using below curl command from terminal you can post data -
curl -d 'my request data' http://<nifihostname>:8889/curlRequestListener
'my request data' is the sample data which I am posting to the ListenHTTP processor and same is received in processors and queued as flowfile.
Received request Flowfile content -
Created 06-04-2020 02:33 AM
awesome thanks @hegdemahendra
Created 11-30-2021 04:51 AM
I have tried listenhttp processor. But I'm getting following error.
ListenHTTP[id=70ce3e99-017d-1000-1516-26d82190ff59] Failed to process session due to Failed to initialize the server: java.net.BindException: Address already in use: bind ↳ causes: java.io.IOException: Failed to bind to 0.0.0.0/0.0.0.0:8443 ↳ causes: org.apache.nifi.processor.exception.ProcessException: Failed to initialize the server
Can you help me in fixing this
Created 10-20-2022 12:29 AM