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

Camera Errors with aiohttp 2.0.5 #6859

Closed
mezz64 opened this issue Mar 31, 2017 · 9 comments · Fixed by #6862 or #7825
Closed

Camera Errors with aiohttp 2.0.5 #6859

mezz64 opened this issue Mar 31, 2017 · 9 comments · Fixed by #6862 or #7825
Milestone

Comments

@mezz64
Copy link
Contributor

mezz64 commented Mar 31, 2017

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
Latest dev

Python release (python3 --version):
3.5

Component/platform:
Camera - Generic & Mjpeg

Description of problem:
Aiohttp error is thrown repeatedly and cameras no longer appear in hass.

Expected:
Cameras work as before.

Problem-relevant configuration.yaml entries and steps to reproduce:
Configure a generic of mjpeg camera, wait about 10mins. Things work fine at first.

Traceback (if applicable):

17-03-30 22:01:03 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/camera/__init__.py", line 267, in handle
    image = yield from camera.async_camera_image()
  File "/usr/src/app/homeassistant/components/camera/mjpeg.py", line 99, in async_camera_image
    self._still_image_url, auth=self._auth)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/client.py", line 616, in __iter__
    resp = yield from self._coro
  File "/usr/local/lib/python3.5/site-packages/aiohttp/client.py", line 225, in _request
    conn = yield from self._connector.connect(req)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/connector.py", line 364, in connect
    yield from fut
  File "uvloop/future.pyx", line 230, in __iter__ (uvloop/loop.c:110600)
  File "uvloop/future.pyx", line 432, in uvloop.loop.BaseTask._fast_wakeup (uvloop/loop.c:113980)
  File "uvloop/future.pyx", line 96, in uvloop.loop.BaseFuture._result_impl (uvloop/loop.c:108829)
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 430, in start
    yield from resp.write_eof()
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_response.py", line 574, in write_eof
    yield from super().write_eof(body)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_response.py", line 413, in write_eof
    yield from self._payload_writer.write_eof(data)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/http_writer.py", line 281, in write_eof
    yield from self.drain(True)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/http_writer.py", line 291, in drain
    self._transport.write(b''.join(self._buffer))
  File "uvloop/handles/stream.pyx", line 632, in uvloop.loop.UVStream.write (uvloop/loop.c:74612)
  File "uvloop/handles/handle.pyx", line 150, in uvloop.loop.UVHandle._ensure_alive (uvloop/loop.c:54917)
RuntimeError: unable to perform operation on <TCPTransport closed=True reading=False 0x151cda8>; the handler is closed

Additional info:

@mezz64
Copy link
Contributor Author

mezz64 commented Mar 31, 2017

Also get these after I let it keep running.

17-03-30 22:01:10 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/aiohttp_client.py", line 79, in async_aiohttp_proxy_web
    req = yield from web_coro
  File "/usr/local/lib/python3.5/site-packages/aiohttp/client.py", line 616, in __iter__
    resp = yield from self._coro
  File "/usr/local/lib/python3.5/site-packages/aiohttp/client.py", line 225, in _request
    conn = yield from self._connector.connect(req)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/connector.py", line 364, in connect
    yield from fut
  File "uvloop/future.pyx", line 230, in __iter__ (uvloop/loop.c:110600)
  File "uvloop/future.pyx", line 432, in uvloop.loop.BaseTask._fast_wakeup (uvloop/loop.c:113980)
  File "uvloop/future.pyx", line 96, in uvloop.loop.BaseFuture._result_impl (uvloop/loop.c:108829)
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 430, in start
    yield from resp.write_eof()
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_response.py", line 574, in write_eof
    yield from super().write_eof(body)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_response.py", line 413, in write_eof
    yield from self._payload_writer.write_eof(data)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/http_writer.py", line 281, in write_eof
    yield from self.drain(True)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/http_writer.py", line 291, in drain
    self._transport.write(b''.join(self._buffer))
  File "uvloop/handles/stream.pyx", line 632, in uvloop.loop.UVStream.write (uvloop/loop.c:74612)
  File "uvloop/handles/handle.pyx", line 150, in uvloop.loop.UVHandle._ensure_alive (uvloop/loop.c:54917)
RuntimeError: unable to perform operation on <TCPTransport closed=True reading=False 0x2172f58>; the handler is closed

@balloob
Copy link
Member

balloob commented Mar 31, 2017

Can it be that it takes over 10 seconds to get a reply from your camera?

@balloob
Copy link
Member

balloob commented Mar 31, 2017

Nevermind, it looks like CancelledError are raised when the browser closes mid-request.

@mezz64
Copy link
Contributor Author

mezz64 commented Apr 1, 2017

@balloob This isn't constant after #6862 if I don't utilize the hass mjpeg proxy functions. If I have an active proxy client or opening up the camera stream dialog and then close it I can still make a cancellation error happen.

17-03-31 23:09:52 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/aiohttp_client.py", line 108, in async_aiohttp_proxy_stream
    data = yield from stream.read(buffer_size)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/streams.py", line 542, in read
    return (yield from super().read(n))
  File "/usr/local/lib/python3.5/site-packages/aiohttp/streams.py", line 298, in read
    yield from self._wait('read')
  File "/usr/local/lib/python3.5/site-packages/aiohttp/streams.py", line 226, in _wait
    yield from waiter
  File "uvloop/future.pyx", line 230, in __iter__ (uvloop/loop.c:110600)
  File "uvloop/future.pyx", line 432, in uvloop.loop.BaseTask._fast_wakeup (uvloop/loop.c:113980)
  File "uvloop/future.pyx", line 96, in uvloop.loop.BaseFuture._result_impl (uvloop/loop.c:108829)
concurrent.futures._base.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 430, in start
    yield from resp.write_eof()
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_response.py", line 574, in write_eof
    yield from super().write_eof(body)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/web_response.py", line 413, in write_eof
    yield from self._payload_writer.write_eof(data)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/http_writer.py", line 281, in write_eof
    yield from self.drain(True)
  File "/usr/local/lib/python3.5/site-packages/aiohttp/http_writer.py", line 291, in drain
    self._transport.write(b''.join(self._buffer))
  File "uvloop/handles/stream.pyx", line 632, in uvloop.loop.UVStream.write (uvloop/loop.c:74612)
  File "uvloop/handles/handle.pyx", line 150, in uvloop.loop.UVHandle._ensure_alive (uvloop/loop.c:54917)
RuntimeError: unable to perform operation on <TCPTransport closed=True reading=False 0x9e4058>; the handler is closed

@balloob
Copy link
Member

balloob commented Apr 1, 2017

Are you 100% sure that you are running the latest version? Because line 108 (start of traceback) is within a try…catch block and we catch the exception CancelledError on line 120

image

@mezz64
Copy link
Contributor Author

mezz64 commented Apr 1, 2017

Yes, 100% sure. Just pulled the latest docker dev build again to double check. Note that the initial errors were coming from aiohttp/connector.py and these are ending at aiohttp/streams.py

@mezz64
Copy link
Contributor Author

mezz64 commented Apr 5, 2017

@balloob Can I give you any more info to help figure this out? Just switched back to the latest dev docker image to double check and still getting the error posted above. It's easily replicated by having a mjpeg camera defined and then have an external application access that cameras proxied mjpeg stream through hass.

@balloob balloob added this to the 0.42 milestone Apr 5, 2017
@balloob
Copy link
Member

balloob commented Apr 6, 2017

I am able to reproduce this issue but only if I use uvloop. Using the normal loop gives no issues.

@balloob
Copy link
Member

balloob commented Apr 6, 2017

@mezz64 this doesn't seem to be related to Home Assistant. I have raised an issue with aiohttp aio-libs/aiohttp#1790

@mezz64 mezz64 mentioned this issue May 30, 2017
1 task
@home-assistant home-assistant locked and limited conversation to collaborators Jul 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants