Created on 11-13-2020 11:40 AM - edited 11-13-2020 11:43 AM
I am using the below Nifi processors
HandleHttpRequest -> RouteOnAttribute -> HandleHttpResponse
My RouteOnAttribute property is test and value is ${http.headers.type:contains('test')}
Below is the sample client request which i sent to nifi server and i am getting response code as 200 same i have mentioned in HandleHttpResponse's http status code which means my configured the processor correctly
import requests
import json
import traceback
nifi_url = "http://localhost:8009/report"
def uploadLogs(fileName):
f = open(fileName, 'rb')
payload = {
"this": "that"
}
files = {'info': (None, json.dumps(payload), 'application/json; charset=utf-8'),
'file': ('current', f, "text/plain; charset=us-ascii")}
headers = {'type': 'test', "Keep-Alive": "timeout=100", "Content-Transfer-Encoding": "8bit",
"Connection": "Keep-Alive"}
url = ''
try:
url = nifi_url
response = requests.post(url, files=files, headers=headers)
print(response.status_code)
if (response != None and (response.status_code == 200 or response.status_code == 201)):
return True
except:
traceback.print_exc()
return False
filename = "C:\\sample.txt"
print(uploadLogs(filename))
Still i am getting below error i would like to know is this error expected if not why i am getting below error and how to fix this error. Any help is appreciated
nifi_1 | 2020-11-13 19:14:09,360 ERROR [Timer-Driven Process Thread-7] o.a.n.p.standard.HandleHttpResponse HandleHttpResponse[id=39d755ed-f825-3013-ce47-5218721d27d4] Failed to respond to HTTP request for StandardFlowFileRecord[uuid=1a422f48-41e3-4eb9-9390-73b12762c5dc,claim=StandardContentClaim [resourceClaim=StandardResourceClaim[id=1605269814303-549, container=default, section=549], offset=39642, length=16],offset=0,name=1a422f48-41e3-4eb9-9390-73b12762c5dc,size=16] because FlowFile had an 'http.context.identifier' attribute of 5e7dc338-8684-491d-a554-6392e2a0e3b9 but could not find an HTTP Response Object for this identifier
Created 11-13-2020 12:41 PM
I sometimes see these errors when a long amount of time is spent testing within the flow from the handhttprequest through to the handlehttpresponse. You no longer have an active connection to the original requesting client. If you test the flow entirely with a single request do you still get the error?
Created 11-14-2020 10:00 AM
for me it always comes , regarding " If you test the flow entirely with a single request do you still get the error?" do you mean single request instead of multipart-form data? Is there any way i can fix the active connection to the original request?
Created 11-14-2020 10:28 AM
I have attched nifi configuration file in this url https://www.dropbox.com/s/dyvxduepz94vwct/simple_request_response_template.xml?dl=0 please check and let me know any issue in configuration settings
Created 11-16-2020 09:31 AM
@manas_mandal786 Thanks for providing template. The next thing I wanted to look at was configs so you read my mind. I was able to import your template, start the context service, and add success/failure routes for each test to an output port (so i can see results are success/fail). With the workflow setup I execute 2 curl calls:
curl -L -X POST 'http://localhost:8009/report' -H 'Content-Type: multipart/form-data' -F test=test
curl -L -X POST 'http://localhost:8009/report' -H 'Content-Type: multipart/form-data' -H 'ReportType: test' -F test=test
And my canvas looks like this:
I did not get any warnings. Everything worked as expected. If you are still getting issues, i suspect it is something to do with your environment (windows) not being able to store the metadata for the StandardSSLContext Service. This store will hold the client connection until you send the response. In your case that part does not seem to be working. Look for any errors/warnings in nifi-app.log while testing. You may see warnings in the Controller Services window on the StandardSSLContext. You may need to set each processor to DEBUG in order to find more info in the nifi-app.log.