Skip to content

Instantly share code, notes, and snippets.

@niemyjski
Created January 19, 2020 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niemyjski/6ba88dcdca7e76172c58530bac66eada to your computer and use it in GitHub Desktop.
Save niemyjski/6ba88dcdca7e76172c58530bac66eada to your computer and use it in GitHub Desktop.
Kohler DTV+ Proxy Disconnect Issue

Steps to reproduce:

  1. Install Python 3.x and pip3 install aiohttp and requests
  2. Run this command via python main.py

Possible Core Issues:

  1. Incorrectly configured server side proxy that is terminating the request too soon.
  2. This is a malformed http response: aio-libs/aiohttp#3402 (comment)

Requests Error

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1344, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 288, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: {......json response...

AIOHTTP Error

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_proto.py", line 201, in data_received
    messages, upgraded, tail = self._parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message='invalid constant string'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 18, in <module>
    loop.run_until_complete(main())
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 583, in run_until_complete
    return future.result()
  File "main.py", line 12, in main
    async with session.get(url) as resp:
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 852, in start
    message=exc.message, headers=exc.headers) from exc
aiohttp.client_exceptions.ClientResponseError: 400, message='invalid constant string', url=URL('http://IP_OF_SHOWER_CONTROLLER_HERE/values.cgi?_=1579384493390')
import aiohttp
import asyncio
import requests
async def main():
url = "http://IP_OF_SHOWER_CONTROLLER_HERE/values.cgi?_=1579384493390"
response = requests.get(url)
print(response.json())
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
print(resp.status)
print(await resp.json())
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment