You are doing a lot of things while still within the request handler , these things are simply taking longer than a reasonable HTTP timeout.
Maybe you could decouple the incoming request from the action , so the incoming request sets a flag which is polled for by a service which does the work outside the request.