#1
  1. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,998
    Rep Power
    375

    Api returning bad gateway - solutions?


    Ok we create landing pages for users to come and fill in their details. These details are then passed to our "database" via an API.

    Now I have created a landing page & it is receiving "high usage" and teh API is returning bad gateway.

    I have implemented it so that I get emailed the user details if this happens (although the company doesnt want to do this because they only want to store user details in their "database".)

    I have thought of doing a "retry" if it fails in the code so something like:

    PHP Code:
    try {
      
    //send details
    } catch() {
      
    retry(); 

    but surely if i re-try it would place an additional pressure on the API?
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Why does your app not have direct access to the database?

    And why is it your problem that the API fails regularly?

    This isn't a problem in your code. If it's happening enough for you to ask how to get around it, the real answer is to fix the API so it's more reliable.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,998
    Rep Power
    375
    yeah i know, i have raised a ticket. but i thought to do something in the meantime.

    because my "db" is actually situated somewhere else, we have a UI for it, we cant run queries or anything.. its a bit complicated hence my use of quotes around db i.e. "db".

    Not sure what is going wrong, up until today it was working fine.

    instead of retrying, what i have done is create a csv file, which I will have to create a script for to send the user data to my "db" at a later stage.
    Last edited by paulh1983; June 25th, 2013 at 08:57 AM.
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Quite the hack, but at least it will work for the time being. Whoever is upset you have to use emails, tell them to help you drive the fix to this "api" or "database" or whatever they want to call it.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,998
    Rep Power
    375
    thanks as always.

IMN logo majestic logo threadwatch logo seochat tools logo