Coder Social home page Coder Social logo

Comments (3)

stcheng avatar stcheng commented on April 27, 2024

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?

from facebook-python-business-sdk.

wrong1man avatar wrong1man commented on April 27, 2024

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.

from facebook-python-business-sdk.

wrong1man avatar wrong1man commented on April 27, 2024

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?

from facebook-python-business-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.