I'm using this package to add Google Cloud tasks to my project and it works perfectly. The problem is that I can't figure out how to increase http target request timeout?
Use dispatchDeadline
if you are creating a task using nodejs.
Source: https://googleapis.dev/nodejs/tasks/latest/google.cloud.tasks.v2beta3.Task.html
Example implementation:
//npm install --save @google-cloud/tasks
const client = new CloudTasksClient();
const project = 'your-project-name';
const queue = 'your-queue-name';
const location = 'us-central1';
const parent = client.queuePath(project, location, queue);
const serviceAccountEmail = 'user@projectname_or_whatever.iam.gserviceaccount.com';
const url = 'http://destination_url'
const payload = JSON.stringify({ "user": "Manuel Solalinde", 'mode': 'secret mode' })
const body = Buffer.from(payload).toString('base64')
// task creation documentation: https://googleapis.dev/nodejs/tasks/latest/google.cloud.tasks.v2beta3.Task.html
const task = {
httpRequest: {
httpMethod: 'POST',
url: url,
dispatchDeadline: 30 * 60, //30 minutes
body: body,
headers: { "Content-type": "application/json" },
oidcToken: {
serviceAccountEmail,
},
},
};
// Send create task request.
console.log('Sending task:');
const [response] = await client.createTask({ parent, task });
console.log(`Created task ${response.name}`);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With