3

I have a working celery flower project.
Now I want some celery failed task details using flower http api, but my celery is using --basic-auth for authentication and when I make a request at flower http api on http://localhost:5555/api/tasks it timeouts and does not show any results.

I did not understand if this is an auth problem or something else. I look to flower docs but i did not get any idea. Thanks for you time. Below is the code that is not working for me.

import requests

params = (('state', 'FAILURE'),('limit', '5'),)

requests.get('http://localhost:5555/api/tasks', params=params)
John Moutafis
  • 22,254
  • 11
  • 68
  • 112
Manish Yadav
  • 435
  • 2
  • 8
  • 24

1 Answers1

5

Then you should make your request with your credentials:

  1. Import HTTPBasicAuth (since you are using --basic-auth):

    from requests.auth import HTTPBasicAuth
    
  2. Make an authenticated request:

    requests.get(
        'http://localhost:5555/api/tasks', 
        auth=HTTPBasicAuth('your_user', 'your_pass'), 
        params=params
    )
    

Good luck :)

John Moutafis
  • 22,254
  • 11
  • 68
  • 112
  • thanks for quick response but its give me error requests.exceptions.ConnectionError: HTTPSConnectionPool(host='139.172.59.25', port=5555): Max retries exceeded with url: /api/tasks?state=FAILURE&limit=5 (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 110] Connection timed out',)) – Manish Yadav Jun 07 '17 at 13:33
  • @ManishYadav That seems to be a different issue. Take a look at this answer: https://stackoverflow.com/questions/23013220/max-retries-exceeded-with-url?answertab=votes#tab-top and at this requests issue: https://github.com/requests/requests/issues/1198 – John Moutafis Jun 07 '17 at 13:46