Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSE request Error: Line is too long #118

Closed
andreasbrinch opened this issue Mar 26, 2020 · 10 comments
Closed

SSE request Error: Line is too long #118

andreasbrinch opened this issue Mar 26, 2020 · 10 comments

Comments

@andreasbrinch
Copy link

andreasbrinch commented Mar 26, 2020

I get these in my log. I can't see exactly what triggers them but it doesn't look good.

HABApp Version 0.12.5

[2020-03-26 16:35:33,442] [HABApp.openhab.connection]    ERROR | SSE request Error: Line is too long
[2020-03-26 16:35:33,442] [HABApp.openhab.connection]    ERROR | Traceback (most recent call last):
[2020-03-26 16:35:33,442] [HABApp.openhab.connection]    ERROR |   File "/usr/src/app/HABApp/openhab/http_connection.py", line 218, in async_process_sse_events
[2020-03-26 16:35:33,442] [HABApp.openhab.connection]    ERROR |     async for event in event_source:
[2020-03-26 16:35:33,443] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/site-packages/aiohttp_sse_client/client.py", line 146, in __anext__
[2020-03-26 16:35:33,443] [HABApp.openhab.connection]    ERROR |     async for line_in_bytes in self._response.content:
[2020-03-26 16:35:33,443] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 39, in __anext__
[2020-03-26 16:35:33,443] [HABApp.openhab.connection]    ERROR |     rv = await self.read_func()
[2020-03-26 16:35:33,443] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/site-packages/aiohttp/streams.py", line 322, in readline
[2020-03-26 16:35:33,443] [HABApp.openhab.connection]    ERROR |     raise ValueError('Line is too long')
[2020-03-26 16:35:33,443] [HABApp.openhab.connection]    ERROR | ValueError: Line is too long
[2020-03-26 16:35:33,443] [HABApp.openhab.connection]  WARNING | Disconnected! Uncaught error in process_sse_events: Line is too long
[2020-03-26 16:35:38,456] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance c864cc55-46da-4490-9ed3-3aa316980f30
[2020-03-26 16:35:38,623] [                   HABApp]    ERROR | Error 100 in update_all_items:
[2020-03-26 16:35:38,626] [                   HABApp]    ERROR | Traceback (most recent call last):
[2020-03-26 16:35:38,629] [                   HABApp]    ERROR |   File "/usr/src/app/HABApp/openhab/oh_connection.py", line 162, in update_all_items
[2020-03-26 16:35:38,630] [                   HABApp]    ERROR |     existing_item.set_value(new_item.value)  # use the converted state from the new item here
[2020-03-26 16:35:38,630] [                   HABApp]    ERROR |   File "/usr/src/app/HABApp/openhab/items/dimmer_item.py", line 19, in set_value
[2020-03-26 16:35:38,630] [                   HABApp]    ERROR |     assert new_value is None, new_value
[2020-03-26 16:35:38,630] [                   HABApp]    ERROR | AssertionError: 100
@spacemanspiff2007
Copy link
Owner

spacemanspiff2007 commented Mar 27, 2020

Do you use images or items which huge strings in your installation?
Which version of openhab are you running? Can you find out which Dimmer item is causing the issue?

Ref:
aio-libs/aiohttp#4453

@andreasbrinch
Copy link
Author

andreasbrinch commented Mar 27, 2020

I am using images in my installation. Mostly graphs in the sitemap but I think there are some thumbnail items too. I will try to identify the dimmer.

The openhab version is 2.5.3 release on docker.

@spacemanspiff2007
Copy link
Owner

Can you check if there are images which are > 100kbytes and see if it works if you remove them?
There seems to be a limitation in the underlying http library.

@andreasbrinch
Copy link
Author

None of the images I generate myself are more than 100 kb and I have removed all image items. As I don't know exactly what triggered the error I will have to wait and see if it happens again.

@spacemanspiff2007
Copy link
Owner

spacemanspiff2007 commented Mar 27, 2020

Imho the size limit must be somewhere around 85kbyte.
If you can reproduce the error it would be very nice if you could let me know.

Edit:
I can reproduce the issue and its at around 49kbyte.

@spacemanspiff2007
Copy link
Owner

@andreasbrinch :
I am really sorry that I can't fix this on my own. I've created the required PR long ago, but it still hasn't been merged.
If you would switch from docker to a virtual environment I can give you a hint how you can change the value responsible in the python file.

@TomaszKn
Copy link

TomaszKn commented Sep 20, 2020

[2020-09-20 15:44:17,958] [                   HABApp]     INFO | HABApp Version 0.15.1
[2020-09-20 15:44:17,960] [   HABApp.mqtt.connection]     INFO | Connecting to localhost:1883
[2020-09-20 15:44:17,960] [    HABApp.RuleParameters]     INFO | Parameter files disabled: Folder /etc/habapp/param does not exist!
[2020-09-20 15:44:17,978] [HABApp.openhab.connection]     INFO | Connected to OpenHAB instance f8f0e653-9101-4c88-8d73-4097805506d7
[2020-09-20 15:44:18,032] [     HABApp.openhab.items]     INFO | Updated 207 Items
[2020-09-20 15:44:18,036] [HABApp.openhab.connection]    ERROR | SSE request Error: Line is too long
[2020-09-20 15:44:18,036] [HABApp.openhab.connection]    ERROR | Traceback (most recent call last):
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/HABApp/openhab/connection_handler/http_connection.py", line 248, in sta$
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR |     async for event in event_source:
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/aiohttp_sse_client/client.py", line 148, in __anext__
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR |     async for line_in_bytes in self._response.content:
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/aiohttp/streams.py", line 39, in __anext__
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR |     rv = await self.read_func()
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/aiohttp/streams.py", line 322, in readline
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR |     raise ValueError('Line is too long')
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]    ERROR | ValueError: Line is too long
[2020-09-20 15:44:18,037] [HABApp.openhab.connection]  WARNING | Disconnected! Uncaught error in process_sse_events: Line is too long
[2020-09-20 15:44:18,038] [HABApp.openhab.connection]    ERROR | "" (<class 'concurrent.futures._base.CancelledError'>)
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR | Traceback (most recent call last):
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/HABApp/openhab/connection_handler/func_async.py", line 85, in async_get$
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |     resp = await get('things')
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/HABApp/openhab/connection_handler/http_connection.py", line 53, in get
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |     return await check_response(mgr, log_404=log_404)
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/HABApp/openhab/connection_handler/http_connection.py", line 152, in che$
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |     resp = await future
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/aiohttp/client.py", line 504, in _request
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |     await resp.start(conn)
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/aiohttp/client_reqrep.py", line 847, in start
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |     message, payload = await self._protocol.read()  # type: ignore  # noqa
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |   File "/usr/local/lib/python3.7/dist-packages/aiohttp/streams.py", line 591, in read
[2020-09-20 15:44:18,039] [HABApp.openhab.connection]    ERROR |     await self._waiter
[2020-09-20 15:44:18,040] [HABApp.openhab.connection]    ERROR | concurrent.futures._base.CancelledError

I'm have the same problem.
In my openhab I use a few big images, capture from my IP Camera.

Any progress ?

@spacemanspiff2007
Copy link
Owner

I have created a PR in April which passes with all tests but it still hasn't gotten merged.
If you run HABApp in a virtual environment you can increase the buffer size with this line (don't forget to restart):
https://github.com/aio-libs/aiohttp/blob/5f0a59fd38f048ee65b6199a26d2355075d0d196/aiohttp/streams.py#L20

@spacemanspiff2007
Copy link
Owner

In the latest dev branch I increased the possible image size to about ~200k.
Would this be enough for you?

@spacemanspiff2007
Copy link
Owner

1.0 adds a config option for the buffer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants