Http as a source for Nifi - not working as expected - apache-nifi

I am trying to send a file through postman with a POST request and that file needs to be saved in the local FS. I tried all the 4 options GetHttp,InvokeHttp,ListenHttp,HandleHttpRequest. Seems like GetHttp,InvokeHttp requires a webservice to be running at the end who is sending the POST request, that would not fit our case use case. I tried using ListenHttp but I am not able to change the default hostname option which it is pointing to localhost. Is there a way to change that?
And I tried using HandleHttpRequest as well, and it seems like the client who is receiving the request should send an acknowledgement to end the connection at the sender side, nifi user guide doesn't provide an example on how to use or configure that. Can someone provide me an example for the use case which I mentioned.

ListenHttp starts an embedded Jetty server and it does not specify a hostname when creating the connector which according to Jetty documentation says that it should be binding to all available network interfaces:
"The network interface this connector binds to as an IP address or a
hostname. If null or 0.0.0.0, then bind to all interfaces."
To use HandleHttpRequest you also need to use HandleHttpResponse... you basically receive a request from a client which turns into a flow file, pass the flow file through whatever processing you want to do, and then send it to HandleHttpResponse to reply back to the client. There is a template here that shows how to use it:
https://cwiki.apache.org/confluence/download/attachments/57904847/Hello_NiFi_Web_Service.xml?version=1&modificationDate=1449369797000&api=v2

Related

YARP simple direct forwarding configuration

I have a web api application built with yarp support listening on port 443.
I know it is up and running because postman says so when https://myserver/info. 'Info' is a simple http GET returning some strings from a simple controller.
I also have a web api project listening on port 5002 which I know is functioning because postman says so when https://myserver:5002/myotherapp/info.
I would like postman to tell me that https://myserver/myotherapp/info is also valid, but have not been able to configure it so.
I have tried numerous different combinations in the appsettings.json to achieve this but to no avail. All I am trying to do is direct to localhost:5002 on the server. In my current setup I am seeing 503 Service Unavailable in postman.
It may not be a configuration issue but could someone assist me by confirming what the ReverseProxy element of appsettings.json should look like in this simplest of cases?

What happens if UI makes a rest call and the server stops?

Suppose, UI is making calls to rest service and the server stops.
Does UI come to know about the server's state?
Does UI get any response back from the server?
What difference does it make if the rest call was POST or PUT?
When REST Api is stopped,the UI/Browser/Client will show "Could not get any response
There was an error connecting to " error, irrespective of request type: PUT /POST.
To answer your questions :
Does UI come to know about the server's state?
If Server stops, you will get an error like : error connecting server. Which can be traced to multiple rootcauses. One of them can be : Server has stopped.
In case of error, Server's state can be sent to client using various error codes like:
500 Internal Server Error The 500 status code, or Internal Server Error, means that server cannot process the request for an unknown reason. Here is list of status codes for REST APis: https://www.w3.org/Protocols/HTTP/HTRESP.html
Does UI get any response back from the server?
If server is stopped, UI/Client will receive no response.
What difference does it make if the rest call was POST or PUT?
If the server has stopped, it doesn't make any difference.
You can run this scenario using a browser and running any app/REST service in your local machine.
(For this test you need not have any REST application running in your local, as you only want to test when it is stopped)
For instance, if your REST application server is up and available at port 8080, you can send request to this server by sending request form your browser : http://localhost:8080
For testing with POST/PUT collections, you can use any API Development tools like : Postman.
Let's assue your REST Api , exposes following urls :
/myPostRequest POST
/myPutRequest PUT
When you hit these urls from POSTMAN you get the same response :
POST http://localhost:8080/myPostRequest :
Could not get any response
There was an error connecting to http://localhost:8080/transition-order.
PUT http://localhost:8080/myPutRequest :
Could not get any response
There was an error connecting to http://localhost:8080/transition-order.
Client(could be UI) and Server are two dumb applications. They do and say what they are told to.
So whenever a client tries to call a server on a socket and there is no server listening to it, there is no response returned to the client. The client can interpret it in whatever way it wants. Most of the browsers show <host> refused to connect.
But if a server is listening to a socket, it responds to the client whichever way it was programmed to do. The server sends an appropriate status code and expects that the client knows how to interpret it. A server can send any random number it wants... the catch is, the client must know how to interpret it. otherwise, it's just one-way communication.
In order to provide smooth client-server communication, section 10 of RFC 2616 defines various codes with specific meaning as shown here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
These status codes are the same for all the types of Http methods.

Nifi: PostHTTP Cannot send data to localhost:3000 because the destination does not accept FlowFiles

I am new to Nifi and I am trying to do a PostHttp to send XML/JSON data to an nodejs app (it's on Localhost:3000)
I am using this processors:
But I get the next error: PostHTTP Cannot send data to localhost:3000 because the destination does not accept FlowFiles and this processor is configureto deliver flowfiles.
Do I need to use other type of processor?
The App side, works properly (I have tried doing Posts with Insomnia)
Try changing the property "Send as FlowFile" to "false" in PostHTTP.

DNS solution for Dante SOCKS proxy

I am trying to build a SOCKS solution for forward proxy. I am using dante SOCKS proxy as I have heard that big companies like google uses it as forward proxy solution.
on the SOCKS server, I am allowing based on FQDN's like google.com:443
Now the problem is, when the client constructs the packet, it tries to resolve google.com and gets X.X.X.X and sends connect request to SOCKS server. Now when the server receives the packets, it tries to reconstruct the packet to send out to internet, the server again does DNS resolution and if the server gets response as Y.Y.Y.Y, then it doesn't allow client's request as the destination IP in the client's request is different then the server's resolved IP address.
There was a solution in dante client which tells client to put a dummy destination address 0.0.0.1 and sends request to server and server processes it properly then. However that is creating a problem with internal domains as after using that dns resolution method, every requests goes through dante server :(
Please let me know
If there is any solution through which would help me in maintaining a DNS record expiry DC wide for e.g. google.com resolves to X.X.X.X and I should be able to resolve to this same IP address on 100's of DNS client and in case if the record changes, then it should immediately change/expire on client.
Any other proxy/socks solution which should be transparent to applications for forward proxy
I went ahead with this solution in case anyone is curious to see the solution.
I used PowerDNS Auth Server with Pipe backend. The requests would land to PowerDNS server for resolution, it will pass on all the data to Pipe backend script with ABI, the script analysis the requests, sees if it is present under cached variable/memory map, if it is cache hit, it will respond using cached DNS records else it will use a DNS resolver to resolve that query like a resolver resolves normally.
PowerDNS version lower than 4.1 supports Pipe backend + resolver. This way, the request would first land to pipe backend script, if the script doesn't have any entries cached, it will not respond or will respond blank and then PowerDNS would resolve it with the mentioned resolver server in the configuration. However with version 4.1 and above, the resolver part is removed from PowerDNS Auth server hence you need to handle that behaviour via Pipe backend script.
It depends on your client. Firefox, for example, sends hostname to SOCKS proxy without resolving it. You can confirm that by Wireshark.
PS. assume you are using a SOCKS5/4a proxy. SOCKS4 does not support hostname. Ref: https://en.wikipedia.org/wiki/SOCKS#SOCKS4a

Howto make SimpleWebRTC Directly Connect to my Websocket URL

By default, SimpleWebRTC uses https://sandbox.simplewebrtc.com:443/ as its signaling server. Now, this is an XHR endpoint, and somehow, signal master seems to switch it to a web socket connection.
Now, I’m trying to use my own signaling server with SimpleWebRTC. And it’s a straightforward websocket endpoint. So when creating the SimpleWebRTC object, I have SimpleWebRTC { “url” : ”ws://<my-IP>/chatroom" ...}
But upon creating the SimpleWebRTC object, it proceeds to try and connect to a different URI: http://my-IP/socket.io/?EIO=3&transport=polling&t=1450985796761-0.
How can I get SimpleWebRTC to just connect directly to ws://my-IP/chatroom, and have those parameters just passed along to other peers as signal master does? Does my signaling server have to do anything other than pass along the parameters / message that the initiator sends?
SimpleWebRTC uses socket.io instead of raw websockets. If you want to use raw websockets you can try replacing https://github.com/andyet/SimpleWebRTC/blob/master/socketioconnection.js with your raw websocket connection.
Or you implement the socket.io protocol in your server.
Here is signal master for your question:
github signalmaster
For run it, you must to install module of npm in server.js file.
Replace:
https://sandbox.simplewebrtc.com:443/
↓
http://<yourip>:8888/
But I don't understand, if we using that signal server, can we increase performance of frame rate and speed, and no need stun and turn server of google? When I deployed that signalserver on my cloud host? BTW, I can't understand when reading config for install turnserver on github.

Resources