HTTP error code 0 (on just 1 system)

I’m getting HTTP status error 0 when accessing one of my Anvil apps. The exception status code is 0 and the content is None.

I am aware of Anvil Docs | Making HTTP requests.

The weird thing is that running the same app on other systems (on the same network) works fine. So a CORS problem seems unlikely.

The call that yields the error is a call to Rollbar:

def send_rollbar_message(msg, level='error'):  
  payload = {
    'access_token': '<redacted>',
    'data': {
      'environment': anvil.app.branch,
      'platform': 'browser',
      'framework': 'anvil',
      'level': level,
      'body': {
        'message': {
          'body': msg
        }
      }
    }
  }
  try:
    anvil.http.request('https://api.rollbar.com/api/1/item/', method='POST', json=True, data=payload)
  except anvil.http.HttpError as e:
    print(f'HTTP error {e.status} when calling Rollbar with content {e.content}')
    raise

On the system in question (a raspberry pi) I can do a ping to api.rollbar.com just fine.

Any ideas? TIA

Hi @mjmare,

So, this error is being returned directly from the browser, which suggests we should look there for differences (perhaps different policies between browsers?). Things to check:

  • Which browser are you using on the Pi?
  • What is it saying on its JS console? (Chrome usually prints some sort of explanation of why it just blocked an HTTP request)
  • Is it accessing the same hostname as the other systems you’re trying with? (Eg if you’re playing with the App Server and loading your app from localhost, it can trigger different rules vs doing cross-origin between two public HTTPS origins)

Yes the code is browser code.
I’m using chrome in kiosk mode on the pi.
Will try to get to the browser console (bit of a challenge since it runs full screen w/o keyboard/mouse).
The running app is identical to the one run on other systems. Please note (I was not clear on this) that the HTTP Error 0 occurs only every so often, not always.