I'm setting up a simple web server using Apache NiFi with HandleHttpRequest and HandleHttpResponse. The goal is to handle multiple GET endpoints like:
Here's what I did:
Configured HandleHttpRequest processor:
Allowed Paths: ^(\/api\/.*|\/accdetails)$
HTTP Method: GET
Expiration Timeout: 5 mins (increased from the default 1 min)
Observed Behavior: When I hit http://localhost:/accdetails, it works as expected. When I hit http://localhost:/api/accdetails, I get the following error in the logs:
StandardHttpContextMap[id=3829e85d-0196-1000-d070-e882bfb48ab3] Request from 127.0.0.1 timed out; responding with SERVICE_UNAVAILABLE
What I Tried Next: Changed the Allowed Paths to explicitly define /api/accdetails. After this change, I started getting a new error:
StandardHttpContextMap[id=3829e85d-0196-1000-d070-e882bfb48ab3] Failed to respond with SERVICE_UNAVAILABLE message: java.lang.IllegalStateException: AsyncContext completed and/or Request lifecycle recycled
It seems that the flow isn't responding in time or properly returning the response for /api/* paths.
My Questions:
Any help or pointers would be much appreciated!
Based on my understanding, the HandleHttpRequest.java
servlet configuration currently uses the path "/"
as the base. If we change this to "/api/"
, then all API endpoints will be handled under the /api/
path, meaning requests like /api/yourendpoint
will be routed correctly by default.
final ServletContextHandler handler = new ServletContextHandler();
handler.addServlet(standardServlet, "/");
server.setHandler(handler);
this.server = server;
server.start();