PythonAnywhere Forums

Twilio 11200 Error when trying to access PythonAnywhere - HTTP retreival failure

I occasionally get this error and can't figure out why


From Twilio: "There was a failure attempting to retrieve the contents of this URL. An 11200 error is an indicator of a connection failure between Twilio and your service. When Twilio requests a page from your server, we wait a maximum of 15 seconds for a response. A connection failure will occur if no response is returned in that time."


When I looked at the error more closely it said An attempt to retrieve content from website returned the HTTP status code 403.

I had no errors on the PythonAnywhere logs. This happens every couple days and my code all of sudden won't run. Then If I reload or wait for a while, it will work again.

Any help on this would be appreciated!

how do you do the twillio auth? is it just only run when your website is reloaded?

Actually now that you ask, it is right before the first function. Should I be calling this under the first function?


# Find these values at https://twilio.com/user/account
account_sid = "ID NUMBER"
auth_token = "AUTH TOKEN"
client = TwilioRestClient(account_sid, auth_token)
#---------------


app = Flask(__name__)

@app.route("/", methods=['GET', 'POST'])

def dispatch():

    global c
    global conn
    conn = MySQLdb.connect("mysql.server", *username*, *Name*, *database*)
    c = conn.cursor()

Maybe if twilio times out / logs out the client every couple days, then you would get this error?

I'm getting the same error occasionally and this is frustrating, Auth doesn't seem to be the issue for me (tried it inside the function as well but it doesn't fix the problem.

Anyone else has an idea of what could it be?

From twilio's website :

An 11200 error is an indicator of a connection failure between Twilio and your service. When Twilio requests a page from your server, we wait a maximum of 15 seconds for a response. A connection failure will occur if no response is returned in that time. There are many reasons a connection timeout can occur; common causes are long running database queries or outside processes and calls to external systems taking a long time to return. It may be possible your application experienced one of these issues. If you are encountering this error only intermittently, it is possible that your web server was temporarily unavailable or experiencing a network outage. https://www.twilio.com/console/runtime/debugger/NOa8ddb129977e1dfaf78f85d8c2046f71

what does the code do in your endpoint that twilio hits?

It's a chatbot in a flask app, using twilio SMS as input, retrieving answer using api.ai and then sending the answer using twilio (basically this) with few tweaks, like saving the result in a mySql db.

do you know what version of the twilio client library you're running? can you try upgrading it?