2

I have a python app which pulls xml data through http. I want to run this app on Heroku. The app runs fine on Heroku if I just return "hello world" without trying to pull the xml. When I run this app locally (either by using the 'foreman' command, or just through python directly) it runs completely fine, and the "response.status" is 200, as expected. If I deploy to Heroku, it runs fine up to that point, but I get a response.status: 500 instead, and so cannot retrieve the XML data.

What might be causing this problem?

Here is the relevant function.

Edit: I have tried other URLs with the same results: I get an HTTP status 200 when run locally, but 500 when run on Heroku

def fetchBoBXml():
  # Fetch XML info from BoB
  conn = httplib.HTTPConnection(BOB_DOMAIN, BOB_PORT)
  conn.request("GET", BOB_URL)
  response = conn.getresponse()
  status = response.status
  if status != 200:
    print "BOB response status %s" % status
    raise Exception("BoB HTTP response status: %s" % status)
  data = response.read()
  conn.close()  
  return data
Sixhobbits
  • 1,508
  • 3
  • 17
  • 26
  • Without knowing the URL it is harder to guess. But wouldn't you be better using [`urllib2`](http://docs.python.org/2/library/urllib2.html), instead of [`httplib`](http://docs.python.org/2/library/httplib.html)? – Elias Dorneles Dec 19 '12 at 10:52
  • Oh sorry, the url is to a bidorbuy.co.za sellers xml api feed. It contains the username and password for bidorbuy so I didn't include it. I'll try urllib2 and see if it changes anything .I just don't understand why running the app on heroku should make a difference to an http request/response. – Sixhobbits Dec 19 '12 at 11:03
  • Why don't you use the excellent (newly 1.0) [`requests`](http://docs.python-requests.org/en/v1.0.0/) library instead? Much easier – jdotjdot Dec 19 '12 at 13:01
  • Thanks -- still haven't solved the initial problem, but requests is indeed a brilliant library – Sixhobbits Dec 20 '12 at 10:13
  • 1
    post your logs of the errors – catsby Feb 05 '13 at 15:46
  • Are you setting BOB_PORT to the environment variable PORT? – Eric Fode Feb 26 '13 at 23:47

0 Answers0