#ggmghoul

1 messages ยท Page 1 of 1 (latest)

pliant birchBOT
wintry magnet
#

Hi there!

#

What is your question?

mortal bramble
#

hello

#

so appearently i told you personally days ago about a problem processing the webhook requests which cuts the work of a session to execute the next

#

now i had an idea

#

usually if we execute any request from different ips this doesn't happen

#

so my question is are the stripe requests ,triggered from a webhook, using the same ip ?

wintry magnet
#

a problem processing the webhook requests which cuts the work of a session to execute the next
I'm not sure to understand this part. Can you give more details into what "cuts the work of a session" means?

mortal bramble
#

ofc

#

i'm using sqlalchemy in my code

#

and i'm treating and updating my DB depending on the event type and infos provided

#

when i receive a request i open a session which is sending a request to the the database to get some ids

#

if during this process another request is sent , my app ignores the first process even when it's still running and start the seconde one

#

i figured the only reason might be that i'm receiving 2 requests from the same ip adress

#

isn't it logical ?

wintry magnet
#

I'm not familiar with sqlalchemy, but you should be able to handle multiple incoming requests at the same time. And I don't think the IP address shouldn't have any impact on this.

mortal bramble
#

well in any other case in the project everything goes normally

#

i mean during the process many testers are sending requests and nothing happened

#

that's why i had the idea that the ip is the reason

#

but i wasn't sure it's just an idea that's why i came to ask xD

wintry magnet
mortal bramble
#

yes it's not a stripe problem i'm here just to ask about whether it is the same ip for the requests or not

#

and thank thank you

wintry magnet
mortal bramble
#

i already checked the link and it might be helpfull during some process in the future realted to security matters so thank you

wintry magnet
#

Perfect!

mortal bramble
#

one more thing pls

#

this object cannot be accessed right now because another api request or stripe process is currently accessing it . if you see this error frequestly and we are making multiple concurrent requests to a single object , make your requests serially or at a lower rate

#

i get this error sometimes

wintry magnet
mortal bramble
#

req_AMIcgWfw7dg3JY

heady nacelle
#

Hi there ๐Ÿ‘‹ apologies for the delay. I'm jumping in as my teammate needed to step away.

The error that you described is typically encountered when two requests are made at almost the same time that need to interact with the same object. The first request that is received locks the object, and if it doesn't complete and release the lock before the other request times out then that error is encountered. We talk about that scenario a bit further here:
https://stripe.com/docs/rate-limits#object-lock-timeouts

Learn about API rate limits and how to work with them.

mortal bramble
#

that's my whole problem with the webhook

#

the seconde one takes the place of the first

#

it someone cuts the process

#

is this a solution for this typical problem ?

heady nacelle
#

This is pretty common as we can't guarantee the order of delivery of webhook events.

#

Building a sort of queueing system on your end to help ensure actions happen in the correct order, and to ensure parallel requests interacting on the same object are minimized or avoided, would help mitigate this behavior.

mortal bramble
#

well finally i kinda had my answer xD

#

i've been stuggling since too long trying to figure out why and what i can do

#

by the end of it i just added w sleep function for 3 secondes in the function to make it work for the moment

#

i'll keep those 3 secondes and read about the rate limit to see if it helps entirely or partially

#

can you give me a simple conclusion what is it and what it means ?

#

for instance this line stripe.max_network_retries = 2

#

what it will do inside the code

heady nacelle
#

That setting controls how many times the library will automatically retry a request due to a connection error. So if a request times out or never receives a response, the library will use our idemptotent key functionality to reissue the request, but in such a way that the follow-up requests won't trigger a duplicate action if they were successful previously.

It's mentioned here briefly as a mitigation approach for Connection Issues:
https://stripe.com/docs/error-handling?lang=python#connection-errors

There is also a longer explanation of our idempotent request functionality that these use here:
https://stripe.com/docs/api/idempotent_requests

Catch and respond to declines, invalid data, network problems, and more.

mortal bramble
#

okay i'll check it out

#

i wanted to know if there is a way to change the time between 2 requests from webhook but sadly you teammates told me that the feature doesn't exist

#

well thank you

heady nacelle
#

Yeah, they're right, there isn't a way to add delays to the generation or sending of webhook events.

Happy to help though! Let us know if any other questions arise.