1
votes

I am trying to utilise Tasks on GAE for some async processes.

I can get the Task into the queue, but I keep getting error 302 "App Error" in the logs and they are just retrying constantly.

I am doing this in CodeIgniter, so I'm wondering if the URL parameter is wrong?

Code:

$task = new PushTask('/path/to/endpoint', ['id' => $id]);
$task_name = $task->add();

The path to the end point is relative to the domain, but I think that may be the issue. Using site_url() or base_url() does not work!

My endpoint controller is set to pick up the POST data using:

$id = $this->input->post('id');

app.yaml:

application: <project-name>
version: 1
runtime: php
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: index.php
2
Can you share your app.yaml file? Also does the app return 302 when you hit /path/to/endpoint directly? - Mars
Added yaml. Yes, I can access the endpoint. the issue is connected to the fact CI uses routing to get you to the endpoint, where as I am sure Tasks need to include the endpoint, so you need a standalone script, which CI doesn't have. - Mr Pablo

2 Answers

0
votes

I had the same issue when migrating an exiting program. The task had several included files, and there was an extra "header(url) return" in one of them. This caused both the 302 and the constant retry. Maybe something similar is the cause of your problem.

I also found that any error in the code caused a header response outside of the 200-299 range, causing the task to retry. As my task is an email that gets sent despite the error, I added a queue.yaml file with the task_retry_limit: 0 for extra security against sending a client dozens of the same email.

0
votes

Had the same issue and the reason was simple: the handler for the target url /_ah/queue/xxxxxxxxxxxx had a typo on it so GAE was sending Http302 instead of expected 404 in these case. Once I fixed the url mapping to my handler this solved the issue.