Open wrong1man opened 9 months ago
Hi @wrong1man are there any errors returned from the API call? what are the errors? according to the stack trace, it appears that the request call failed on getting the response. was it taking too long time? have you tried to reproduce by sending raw requests without using sdk?
hey @stcheng
Thank you for your response. Unfortunately, there is no specific error message returned from the API call. The issue that I am facing is that roughly 31% of around 220 events reported by my backend in the last three days have failed. The error traceback I shared earlier is what I get for these failed
I can manually re-trigger them and they usually go through.
To handle this, I've implemented a try-except block to catch all exceptions and log either the API response or the error traceback to a database. Here's the code snippet for your reference:
resp=None
try:
resp = self.send_meta_event(client_ip, client_user_agent, fbc, fbp)
received=resp["events_received"] == True # this allways fails - Logging all events
except:
trace = traceback.format_exc() if not resp else resp
Generic_error_log.objects.create(
function_code="Purchase - send_meta_event",
traceback = str(trace),
related_element_id=f"Dinner_booking - {self.id}"
)
pass
I've recently updated the code to include more information in case of exceptions (but i don't have one of these yet):
except Exception as e:
#...
trace=traceback.format_exc() + "\n"+str(e) if not resp else resp
#...
I am currently logging all events to understand the rate of success and failure. Any suggestions on how to further investigate this issue would be highly appreciated.
Would it be beneficial to log the time it takes to run the meta_api_send_event function? I would expect a timeout error to present itself in the traceback, wouldn't it?
I appreciate your suggestion of attempting to reproduce the issue manually by sending raw requests without using the SDK. However, given the sporadic occurrence of the error, it's been challenging to reproduce it consistently even with the SDK. Furthermore, testing outside of the SDK might not necessarily aid in identifying or resolving the root cause of the issue.
My primary goal is to understand why this error is happening and why the process abruptly aborts. If it's a matter of a timeout, for instance, I could potentially adjust the timeout duration or defer the event reporting to a later time.
In this context, any insights or suggestions that could help me further diagnose this problem would be immensely valuable. Thanks again for your help and cooperation.
Futher investigation revealed it was indeed a timeout. I placed the event reporting on a task queue (celery) sometimes requests take over 3 minutes to complete.
I can re-launch the event report, but its a bit worrying to me that it takes so long to report an event, any ideas on what s happening?
Hello,
I've been using the Facebook Business SDK for Python to report events, but I'm experiencing inconsistent results. Some events are reported successfully, while others fail without a clear explanation from the traceback.
here's the traceback:
and here's the implementation:
The issue seems to occur inconsistently. Some events pass through without any issues, while others fail. I haven't been able to identify a pattern or specific cause for these failures.
The lack of detailed information in the traceback makes it difficult to diagnose and address the issue. I'm hoping for some guidance or insight into what could be causing these inconsistent results.
Thank you for your assistance!