Forums

Error when creating a webhook on Trello

I am getting an error when trying to create a webhook on Trello.

Trello requires me to make a POST request, at which they would then attempt to make a HEAD request at the specified callback URL.

In this case, the callback URL I used was https://antdoodawck.pythonanywhere.com/route (substituting route for the actual route defined in my Python script, of course), and I am getting this error from Trello:

URL (https://antdoodawck.pythonanywhere.com/route) not reachable. TimeoutError: Timeout awaiting 'request' for 10000ms.

It also says:

SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request
uwsgi_response_write_headers_do(): Broken pipe [core/writer.c line 248] during HEAD

Any idea what could be going on and how I could fix it? Many thanks.

That just looks like the request from Trello is timing out for some reason. Perhaps you could put some logging into the /route endpoint to find out why it's taking more than ten seconds? Something like this:

print(f"{datetime.now()} about to do X", flush=True)

...will print a timestamped message to your website's server log (not the error log) so you can dot those around your view code, and find out which part is taking up all of that time.

Thanks for the answer.

This is how the function looks like:

@app.route("/trelloFunction", methods = ["HEAD"])
def init_webhook():
    print("Webhook initialized.")

    return "",200

Upon doing prints before and after print("Webhook initialized."), I got "2022-08-28 15:37:19.569888 about to print" and "2022-08-28 15:37:19.570005 printed" in my server logs. It does not look like it's the print statement that is causing the time out. I suppose it's also worth noting that if I ran the script in a console, it initializes the webhook just fine without timing out.

Do you have other long-running views in your website? Right now your site has two worker processes, which means that you can process two requests at the same time. If you're making some kind of API call to Trello inside a view, and that call will not return until it has made a webhook callback to your site, then that would mean that both workers would be needed at the same time, one to be handling the original request that's making the Trello call, and one to handle the webhook. If someone else was tying up one of your processes, then you could get a deadlock.

It would seem like that is a case, for I have an @app.route("/") which I assume would use up a worker.

In this case, what would be the advised course or action for me? Is there any way to increase the amount of workers that I have?

Yes, you can increase the number of workers by upgrading your account on the Account page.