#Pr4xy(Timothée CLEAR)-webhook timeout
1 messages · Page 1 of 1 (latest)
could you please share more details of what you're trying to accomplish and maybe share the code you're using. if you have a request id that would also be really helpful? here's how you can find one https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
I'm looking at your link thanks
req_JgUKCiJykzNFTO
thx
I
Oh now I see your issue
nice
basically your webhook should reply as fast as possible with a Http 200
if you need to do more time-consuming tasks upon the reception of the webhook event you should probably want to do it asynchronously
it should be a fire and forget type of scenario from the webhook endpoint
So the process I did when I received the webhook event is too long?
yep most probably
ok I'm looking for that thanks
let me know if you need any more help
ok
I just checked, the code I am using is very similar to another payment method that works perfectly, I would be surprised if my function is longer than it
there is another possibility ?
The feature works well, even after the error, it just causes a delay which is annoying.
is there a pattern for getting this error? can you reproduce it?
could you please share your code for that particular switch case?
I can't send you my code, discord bloc it
why?
that is Clyde bot
try to use paste bin or something similar
a
is this getting executed in the webhooks endpoint?
yes
(the first code is the one that doesn't work the second is the function I was inspired by)
even if one of those two functions work, maybe because the query is faster or something, this is not good practice to wait for the execution of that function before responding back to Stripe with an HTTP 200
protected function onPaymentSuccess($row, $transactionId)
{
$config = OSMembershipHelper::getConfig();
$row->transaction_id = $transactionId;
$row->payment_date = gmdate('Y-m-d H:i:s');
$row->published = 1;
$row->store();
if ($row->act == 'upgrade')
{
OSMembershipHelperSubscription::processUpgradeMembership($row);
}
elseif ($row->act == 'update')
{
OSMembershipHelperSubscriber::processUpdateMembership($row);
}
JPluginHelper::importPlugin('osmembership');
JFactory::getApplication()->triggerEvent('onMembershipActive', array($row));
OSMembershipHelper::sendEmails($row, $config);
}```
this is where the function are call in the os_stripe.php
you should build your system in a way that handles tasks that you create from the webhook endpoint but don't wait for it to be executed
I don't understand, the site I'm working on is not mine, I just work after several people. I need to know that the payment was successful before using these functions.
I was just inspired by what was already on the site
The majority of the code provide from a Joomla's module
Hi there 👋 jumping in as my teammate needed to step away. Please bear with me a moment while I get caught up on the context here.
Hello, thank you for your interest in my problem
Apologies, but I'm struggling to grasp what the current question/concern is, would you mind summarizing for me?
I got a timeout error when I use the processUpdateMembership() function, the result is good but this error adds a delay to my request, so I'm trying to find out why it happens.
here is an exemple of this :
Gotcha. We're not really going to have much insight into that. Since you're using the CLI to listen to events, that is essentially the webhook endpoint in this scenario which then immediately forwards events to your local server. So on our end it looks like the event was successfully received (because it was, by the CLI). So all of that processing and the resulting error is being handled locally and we don't have visibility into that. Is your server crashing or raising any errors when you see that timeout?
the server didn't crash but I got this error in a loop until the processing was finished
[Wed May 25 16:53:30.658858 2022] [php7:notice] [pid 9748:tid 1868] [client ::1:53814] Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
Looking back at your processUpdateMembership function, it looks like it's interacting with a database layer, which seems like a task that could easily overrun timeout limitations. This is a bit concerning because we will retry events that fail due to timeouts, so if you don't have some sort of logic to check if the event has already been processed then you'll attempt to process the information repeatedly. It seems to me like your server may have been busy handling the database operations.
What we ask be done instead, is that your server immediately responds to our requests. This response is not intended to track whether your business logic completed successfully, but is rather supposed to be used to confirm that your system received the event. So we recommend handling acknowledgement of receipt first, and then the heavier processing tasks either later or asynchronously.
https://stripe.com/docs/webhooks#acknowledge-events-immediately
Ok I think I understand the probleme
is there any danger in leaving my function like that? I have other things to develop and this code, despite the timeout, produces the expected result.
If I understand correctly, no, but I prefer to ask.
My read on the situation is that your code will likely timeout when receiving an event for the first time, but may return a successful response on the second or third attempt. This isn't ideal, but should be alright as long as you have a way to make sure you're not fully processing the event each time.
The big thing you'll want to avoid is a scenario where our requests always time out, this will result in us flagging the endpoint as problematic and trying to disable it.
Okay, I got it. Thank you very much for your intervention.
I'm done with this topic
Any time, happy to help!
So for my future interaction with this discord server, should I talk here or in the dev-help channel?
We archive threads once the conversation for them comes to an end. If you have a follow-up question you can ask to have the thread re-opened if it was somewhat recent. For new questions you can raise those in #dev-help and we'll start a new thread for them.
ok have a nice day
Thanks, hope you do the same. 👋