question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot decode 502

See original GitHub issue

Looks like Locust doesn’t handle properly 502

[2016-09-21 15:30:12,835] arbalester/ERROR/stderr: Traceback (most recent call last):
[2016-09-21 15:30:12,835] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/gevent/pywsgi.py", line 884, in handle_one_response
[2016-09-21 15:30:12,836] arbalester/ERROR/stderr: self.run_application()
[2016-09-21 15:30:12,836] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/gevent/pywsgi.py", line 870, in run_application
[2016-09-21 15:30:12,836] arbalester/ERROR/stderr: self.result = self.application(self.environ, self.start_response)
[2016-09-21 15:30:12,836] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/flask/app.py", line 2000, in __call__
[2016-09-21 15:30:12,836] arbalester/ERROR/stderr: return self.wsgi_app(environ, start_response)
[2016-09-21 15:30:12,836] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/flask/app.py", line 1991, in wsgi_app
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: response = self.make_response(self.handle_exception(e))
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/flask/app.py", line 1567, in handle_exception
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: reraise(exc_type, exc_value, tb)
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: response = self.full_dispatch_request()
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: rv = self.handle_user_exception(e)
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: reraise(exc_type, exc_value, tb)
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: rv = self.dispatch_request()
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: return self.view_functions[rule.endpoint](**req.view_args)
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/locust/cache.py", line 16, in wrapper
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: cache["result"] = func(*args, **kwargs)
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/home/shipperizer/code/locustio/env/lib/python2.7/site-packages/locust/web.py", line 182, in request_stats
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: return json.dumps(report)
[2016-09-21 15:30:12,837] arbalester/ERROR/stderr: File "/usr/lib64/python2.7/json/__init__.py", line 244, in dumps
[2016-09-21 15:30:12,838] arbalester/ERROR/stderr: return _default_encoder.encode(obj)
[2016-09-21 15:30:12,838] arbalester/ERROR/stderr: File "/usr/lib64/python2.7/json/encoder.py", line 207, in encode
[2016-09-21 15:30:12,838] arbalester/ERROR/stderr: chunks = self.iterencode(o, _one_shot=True)
[2016-09-21 15:30:12,838] arbalester/ERROR/stderr: File "/usr/lib64/python2.7/json/encoder.py", line 270, in iterencode
[2016-09-21 15:30:12,838] arbalester/ERROR/stderr: return _iterencode(o, 0)
[2016-09-21 15:30:12,838] arbalester/ERROR/stderr: File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
[2016-09-21 15:30:12,838] arbalester/ERROR/stderr: raise TypeError(repr(o) + " is not JSON serializable")
[2016-09-21 15:30:12,838] arbalester/ERROR/stderr: TypeError: HTTPError(u'502 Server Error: Bad Gateway for url: http://st-service/api/v1',) is not JSON serializable
[2016-09-21 15:30:12,841] arbalester/ERROR/stderr: {'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': '*/*',
 'HTTP_ACCEPT_ENCODING': 'gzip, deflate, sdch',
 'HTTP_ACCEPT_LANGUAGE': 'en-GB,en-US;q=0.8,en;q=0.6',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_COOKIE': 'cookie-concent=agreed; _ga=GA1.1.1822795932.1465397875; jenkins-timestamper-offset=-3600000; iconSize=16x16; csrf=1v7J3THHOlKkX9RK7b0HLSw71zklIhTm',
 'HTTP_HOST': 'localhost:8089',
 'HTTP_REFERER': 'http://localhost:8089/',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.101 Safari/537.36',
 'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest',
 'PATH_INFO': '/stats/requests',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '127.0.0.1',
 'REMOTE_PORT': '35782',
 'REQUEST_METHOD': 'GET',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'arbalester',
 'SERVER_PORT': '8089',
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SOFTWARE': 'gevent/1.1 Python/2.7',
 'werkzeug.request': <Request 'http://localhost:8089/stats/requests' [GET]>,
 'wsgi.errors': <locust.log.StdErrWrapper object at 0x7fd074e46d10>,
 'wsgi.input': <gevent.pywsgi.Input object at 0x7fd055c89050>,
 'wsgi.multiprocess': False,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)} failed with TypeError

I tried to debug it and this is the result of the var report here https://github.com/locustio/locust/blob/master/locust/web.py#L154 is

{'errors': [{'error': HTTPError(u'502 Server Error: Bad Gateway for url: http://st-service/api/v1',), 'method': 'GET', 'occurences': 2, 'name': '/api/v1/complex'}, {'error': HTTPError(u'502 Server Error: Bad Gateway for url: http://st-service/api/v1f4084ce9-2bc9-440b-aae3-9f62ae626531',), 'method': 'GET', 'occurences': 1, 'name': '/api/v1/f4084ce9-2bc9-440b-aae3-9f62ae626531'}], 'stats': [{'median_response_time': 410, 'min_response_time': 48, 'current_rps': 92.88888888888889, 'name': '/api/v1', 'num_failures': 2, 'max_response_time': 4980, 'avg_content_length': 7413, 'avg_response_time': 528.8645655877342, 'method': 'GET', 'num_requests': 1174}, {'median_response_time': 370, 'min_response_time': 45, 'current_rps': 48.333333333333336, 'name': '/api/v1/f4084ce9-2bc9-440b-aae3-9f62ae626531', 'num_failures': 1, 'max_response_time': 4878, 'avg_content_length': 54, 'avg_response_time': 492.1566666666667, 'method': 'GET', 'num_requests': 600}, {'median_response_time': 370, 'min_response_time': 43, 'current_rps': 50.0, 'name': '/api/v1/f4084ce9-2bc9-440b-aae3-9f62ae626534', 'num_failures': 0, 'max_response_time': 4878, 'avg_content_length': 313, 'avg_response_time': 482.47611202635915, 'method': 'GET', 'num_requests': 607}, {'median_response_time': 370, 'min_response_time': 43, 'current_rps': 191.22222222222223, 'name': 'Total', 'num_failures': 3, 'max_response_time': 4980, 'avg_content_length': 3748, 'avg_response_time': 507.7883242335153, 'method': None, 'num_requests': 2381}], 'state': 'hatching', 'total_rps': 191.22222222222223, 'fail_ratio': 0.0012583892617449664, 'user_count': 944}

therefore fails to json encode the report['errors'][0]['error'] as not built-in (and w/o a defined encoder i presume)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
heymancommented, Sep 21, 2016

Great! Thanks again for reporting.

0reactions
shipperizercommented, Sep 21, 2016

sure, just tried and looks fine now, thanks a lot

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix a 502 Error on a PC - wikiHow Tech
It may be a problem in the Internet connection, where you can't see it at first, that only your ISP will have a...
Read more >
502 Bad Gateway - DecompressionFailureAtResponse
The client application gets an HTTP status code of 502 Bad Gateway with error code messaging.adaptors.http.flow.DecompressionFailureAtResponse as a response ...
Read more >
<Response [502]> cannot be catched - python - Stack Overflow
I am using the interface of a website to get data, and I have run multiple programs at the same time. I wrote...
Read more >
Troubleshooting 502 Errors in ARR - Microsoft Learn
The 502.3 error means that - while acting as a proxy - ARR was unable to complete the request to the upstream server...
Read more >
How do I resolve HTTP 502 errors from API Gateway REST ...
If your Lambda function's permissions are incorrect or the response to the API request isn't formatted correctly, then API Gateway returns an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found