ListenHTTP Questions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ListenHTTP Questions

dale.chang13
So I am having some woes with sending HTTP Post requests to my NiFi server by using curl to send a JSON object.
I have a ListenHTTP Processor running that is configured as so:
- BasePath = contentListener
- ListeningPort = 8011
- Authorized DN Pattern = .*
- Max Unconfirmed FlowFile Time = 60 secs

And I am trying to send a JSON object via curl:
curl -i -X POST -H 'Content-Type: application/json' -d '{"test":"Hello, NiFi"}' http://[hostname for NiFi]:8011/contentListener

And I feel like this needs to be sent elsewhere, but I am thinking that the internal HTTP Server that ListenHTTP creates because I get curl: (7) couldn't connect to host. This usually arises as a result of the server receiving the HTTP request being down, firewall (have none at the moment), and other server errors.

I have been able to successfully use the Rest API to modify Processors, Processor Groups, etc through curl. Is there something I am missing?
Reply | Threaded
Open this post in threaded view
|

Re: ListenHTTP Questions

Mark Payne
Dale,

That should work. I tried exactly that and go the result below.

Can you verify that your ListenHTTP processor is running and that it doesn't show any bulletins?
Have tried to telnet in? I.e., "telnet <hostname> 8011" to see if you can connect that way?

$ curl -i -X POST -H 'Content-Type: application/json' -d '{"test": "Hello, NiFi"}' http://localhost:8011/contentListener
HTTP/1.1 200 OK
Date: Tue, 14 Jun 2016 22:00:53 GMT
Content-Type: text/plain
Content-Length: 0
Server: Jetty(9.2.11.v20150529)

Thanks
-Mark


> On Jun 14, 2016, at 4:46 PM, dale.chang13 <[hidden email]> wrote:
>
> So I am having some woes with sending HTTP Post requests to my NiFi server by
> using curl to send a JSON object.
> I have a ListenHTTP Processor running that is configured as so:
> - BasePath = contentListener
> - ListeningPort = 8011
> - Authorized DN Pattern = .*
> - Max Unconfirmed FlowFile Time = 60 secs
>
> And I am trying to send a JSON object via curl:
> curl -i -X POST -H 'Content-Type: application/json' -d '{"test":"Hello,
> NiFi"}' http://[hostname for NiFi]:8011/contentListener
>
> And I feel like this needs to be sent elsewhere, but I am thinking that the
> internal HTTP Server that ListenHTTP creates because I get /curl: (7)
> couldn't connect to host/. This usually arises as a result of the server
> receiving the HTTP request being down, firewall (have none at the moment),
> and other server errors.
>
> I have been able to successfully use the Rest API to modify Processors,
> Processor Groups, etc through curl. Is there something I am missing?
>
>
>
> --
> View this message in context: http://apache-nifi-developer-list.39713.n7.nabble.com/ListenHTTP-Questions-tp11441.html
> Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: ListenHTTP Questions

dale.chang13
Weird... So we do not have telnet, but I tried again and it worked successfully, but only within the same cluster (VMs that the worker nodes are running on). Performing a curl from the VM that contains the ncm yields a "curl: (7) couldn't connect to host". Likewise for performing a curl from other VMs even if we are on the same subnet.

I would like to be able to use a non-NiFi server, like NodeJS, to send an HTTP request to NiFi. Is there a way I can do that?

Mark Payne wrote
Dale,

That should work. I tried exactly that and go the result below.

Can you verify that your ListenHTTP processor is running and that it doesn't show any bulletins?
Have tried to telnet in? I.e., "telnet <hostname> 8011" to see if you can connect that way?

$ curl -i -X POST -H 'Content-Type: application/json' -d '{"test": "Hello, NiFi"}' http://localhost:8011/contentListener
HTTP/1.1 200 OK
Date: Tue, 14 Jun 2016 22:00:53 GMT
Content-Type: text/plain
Content-Length: 0
Server: Jetty(9.2.11.v20150529)

Thanks
-Mark
Reply | Threaded
Open this post in threaded view
|

Re: ListenHTTP Questions

Mark Payne
Dale,

You can certainly push to ListenHTTP from NodeJS or curl, or whatever other mechanism you want
to use to do POST requests. The fact that you are able to connect from specific nodes sounds like
you have some sort of Firewall / Hypervisor in the way.

Thanks
-Mark


> On Jun 15, 2016, at 7:24 AM, dale.chang13 <[hidden email]> wrote:
>
> Weird... So we do not have telnet, but I tried again and it worked
> successfully, but only within the same cluster (VMs that the worker nodes
> are running on). Performing a curl from the VM that contains the ncm yields
> a "curl: (7) couldn't connect to host". Likewise for performing a curl from
> other VMs even if we are on the same subnet.
>
> I would like to be able to use a non-NiFi server, like NodeJS, to send an
> HTTP request to NiFi. Is there a way I can do that?
>
>
> Mark Payne wrote
>> Dale,
>>
>> That should work. I tried exactly that and go the result below.
>>
>> Can you verify that your ListenHTTP processor is running and that it
>> doesn't show any bulletins?
>> Have tried to telnet in? I.e., "telnet
>> <hostname>
>> 8011" to see if you can connect that way?
>>
>> $ curl -i -X POST -H 'Content-Type: application/json' -d '{"test": "Hello,
>> NiFi"}' http://localhost:8011/contentListener
>> HTTP/1.1 200 OK
>> Date: Tue, 14 Jun 2016 22:00:53 GMT
>> Content-Type: text/plain
>> Content-Length: 0
>> Server: Jetty(9.2.11.v20150529)
>>
>> Thanks
>> -Mark
>
>
>
>
>
> --
> View this message in context: http://apache-nifi-developer-list.39713.n7.nabble.com/ListenHTTP-Questions-tp11441p11462.html
> Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.