Reputation: 961
As far as my server is concerned, the message status updates from recently sent SMS messages are working fine. In the Twilio API, however, it claims that all requests are returning a 502 error with the body:
<html>
<head>
<title>502 Bad Gateway</title>
</head>
<body>
<h1>Bad Gateway</h1>An upstream server returned an invalid response.
</body>
</html>
I've confirmed by placing a filter on outbound traffic both in my application and the firewall that we're returning a blank 200 OK status. Anything that happens between the time I respond and they retrieve the message is completely out of my hands.
Is there anything else that could cause this? Does Twilio interpret non 502 responses as 502 in certain cases?
Upvotes: 0
Views: 486
Reputation: 21720
Twilio developer evangelist here.
I have seen this happening before when I didn't have a Content-Type being returned. Have a look at the information below, and if the problem is not solved after going through the list let me know and we can look at other possible solutions.
If your debugger is reporting a 502 Bad Gateway error, this may mean that Twilio's internal server had trouble retrieving content from your website. Your request must contain a Content-Type that is valid. Twilio may also have had problems resolving your DNS name to an IP address, or issues with the network connection. Check that your web server is started, and is available over the public Internet.
Possible Causes
Web server returned a 4xx or 5xx HTTP response to Twilio Misconfigured Web Server Network disruptions between Twilio and your web server No Content-Type header attached to response Content-Type doesn't match actual content, e.g. an MP3 file that is being served with Content-Type: audio/x-wav, instead of Content-Type: audio/mpeg Possible Solutions
Double check that your TwiML URL does not return a 4xx or 5xx error Make certain that the URL does not perform a 302 redirect to an invalid URL Confirm the URL requested is not protected by HTTP Auth Make sure your web server allows HTTP POST requests to static resources (if the URL refers to .xml or .html files) Verify your web server is up and responsive Check to see that the URL host is not a private or local IP address Verify the ping times and packet loss between your web server and www.twilio.com
Upvotes: 1