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.

Unexpected response body when using WebClient behind a proxy server

See original GitHub issue

I’m at a bit of a loss as to what the issue is here as my code as been working for some time. We are leveraging the WebClient behind a corporate proxy and have set the proxy parameter in the call. Starting today we were experiencing SSL issues which we appear to have resolved. However, now we are running into a JSONDecoder Issue and am at a loss for what the issue may be.

When manually running a curl command we have no issues

curl -X POST https://slack.com/api/api.test\?token\='xoxb....

However when running the WebClient we are experiencing the following issue (included the logging DEBUG for this step as well):

SLACK_CLIENT = slack.WebClient(token='xoxb...',proxy='<corporate proxy>:8099',base_url='https://slack.com/api/')
DEBUG:slack.web.base_client:Sending a request - url: https://slack.com/api/auth.test, query_params: {}, body_params: {}, files: {}, json_body: {}, headers: {'Content-Type': 'application/json;charset=utf-8', 'Authorization': '(redacted)', 'User-Agent': 'Python/3.8.0 slackclient/2.9.0 Linux/4.14.186-146.268.amzn2.x86_64'}
Traceback (most recent call last):
  File "/home/git/.local/lib/python3.8/site-packages/slack/web/base_client.py", line 355, in _urllib_api_call
    response_body_data: dict = json.loads(response["body"])
  File "/opt/runtime/python-3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/runtime/python-3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/runtime/python-3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Any assistance would be greatly appreciated

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jmgreg31commented, Sep 23, 2020

@seratch I double checked that the proxies were set for the requests call as well.

However, using your recommendation of run_async=True seemed to resolve the issue.

SLACK_CLIENT = slack.WebClient(token='<token>',
                               proxy='<proxy>',
                               base_url='https://slack.com/api/',
                               run_async=True)
TEST_SLACK_CLIENT = SLACK_CLIENT.auth_test()

loop = asyncio.get_event_loop()
try:
    response = loop.run_until_complete(TEST_SLACK_CLIENT)
    print(response)
except SlackApiError as e:
    print(f"Got an error: {e.response['error']}")
finally:
    loop.close()

Really appreciate the recommendation!

0reactions
seratchcommented, Sep 23, 2020

This issue has been addressed in version 2.9.1. We’re sorry about this. https://github.com/slackapi/python-slackclient/releases/tag/v2.9.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unexpected response body when using WebClient behind a ...
We are leveraging the WebClient behind a corporate proxy and have set the proxy parameter in the call. Starting today we were experiencing...
Read more >
Proxy setting not working with Spring WebClient
Please help, why my code is not functioning if I set the proxy details via JVM run-time arguments or system properties.
Read more >
The DFHWBCLI Web Client Interface - IBM
DFHWBCLI is a CICS-supplied utility program that you can invoke via EXEC CICS LINK to provide web client services or outbound HTTP.
Read more >
407 Proxy Authentication Required - HTTP - MDN Web Docs
The HTTP 407 Proxy Authentication Required client error status response code indicates that the request has not been applied because it ...
Read more >
502 Bad Gateway Error: What It Is and How to Fix It
An in-depth explanation of what a 502 Bad Gateway Error is, including troubleshooting tips to help you resolve this error.
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