home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.31k stars 30.62k forks source link

Homekit Controller Koogeek #18949

Closed NDNELSON closed 5 years ago

NDNELSON commented 5 years ago

I have this error running hassio.io 0.83.1 :

Error executing service <ServiceCall configurator.configure (c:3f56736447fb48d2b9cd8615f566f639): configure_id=1902096688-2, fields=code=xxx-xx-xxx>
Traceback (most recent call last):
  File “/usr/local/lib/python3.6/site-packages/homeassistant/core.py”, line 1177, in _event_to_service_call
    await service_handler.func(service_call)
  File “/usr/local/lib/python3.6/site-packages/homeassistant/components/configurator.py”, line 221, in async_handle_service_call
    call.data.get(ATTR_FIELDS, {}))
  File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File “/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/init.py”, line 192, in device_config_callback
    pairing_id)
  File “/usr/local/lib/python3.6/site-packages/homekit/protocol.py”, line 69, in perform_pair_setup
    connection.request(‘POST’, ‘/pair-setup’, request_tlv, headers)
  File “/usr/local/lib/python3.6/http/client.py”, line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File “/usr/local/lib/python3.6/http/client.py”, line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File “/usr/local/lib/python3.6/http/client.py”, line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File “/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/init.py”, line 64, in homekit_http_send
    self.send(msg)
  File “/usr/local/lib/python3.6/http/client.py”, line 964, in send
    self.connect()
  File “/usr/local/lib/python3.6/http/client.py”, line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File “/usr/local/lib/python3.6/socket.py”, line 724, in create_connection
    raise err
  File “/usr/local/lib/python3.6/socket.py”, line 713, in create_connection
    sock.connect(sa)
socket.timeout: timed out

How Can I fix it?

cgarwood commented 5 years ago

What does your homekit configuration look like?

rdelcampog commented 5 years ago

I have the same problem:

Error executing service <ServiceCall configurator.configure (c:bdfdcfa65e5e4cb08daa69936298f7d9): configure_id=1867467760-2, fields=code=xxx-xx-xxx>

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1177, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/configurator.py", line 221, in async_handle_service_call
    call.data.get(ATTR_FIELDS, {}))
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 192, in device_config_callback
    pairing_id)
  File "/usr/local/lib/python3.6/site-packages/homekit/protocol.py", line 94, in perform_pair_setup
    resp = connection.getresponse()
  File "/usr/local/lib/python3.6/http/client.py", line 1331, in getresponse
    response.begin()
  File "/usr/local/lib/python3.6/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.6/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

Config:

homekit:
discovery:
  enable:
    - homekit

I have a Koogeek P1EU and LS1 and both have the same problem, can't pair with HASS.

EDIT: I thin is the same as #18241

arkan commented 5 years ago

I have the exact same issue as @rdelcampog (and same configuration)

rdelcampog commented 5 years ago

@arkan @cgarwood @NDNELSON I've just found the problem. Since version 0.79.0 the homekit_controller introduces a 5 seconds timeout. If device needs more than 5 seconds to pair or configure, connection is closed.

Workaround: create the folders: /custom_components/homekit_controller inside /config, create a new file "init.py", copy and paste contents of the library: https://raw.githubusercontent.com/home-assistant/home-assistant/dev/homeassistant/components/homekit_controller/__init__.py and change the line 42 from "REQUEST_TIMEOUT = 5" to "REQUEST_TIMEOUT = 60".

NDNELSON commented 5 years ago

@rdelcampog thanks it works but I have another problem : entity id not shows in my devices list I dont know where is it. And this is my log file:

Error executing service <ServiceCall configurator.configure (c:e8e3fdbb619144429a3690e1138def77): configure_id=1899397168-4, fields=code=XXX-XX-XXX>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/core.py", line 1177, in _event_to_service_call
    await service_handler.func(service_call)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/configurator.py", line 221, in async_handle_service_call
    call.data.get(ATTR_FIELDS, {}))
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/homekit_controller/__init__.py", line 215, in device_config_callback
    self.accessory_setup()
  File "/config/custom_components/homekit_controller/__init__.py", line 137, in accessory_setup
    data = self.get_json('/accessories')
  File "/config/custom_components/homekit_controller/__init__.py", line 164, in get_json
    response = self.securecon.get(target)
AttributeError: 'NoneType' object has no attribute 'get'
aptonline commented 5 years ago

@arkan @cgarwood @NDNELSON I've just found the problem. Since version 0.79.0 the homekit_controller introduces a 5 seconds timeout. If device needs more than 5 seconds to pair or configure, connection is closed.

Workaround: create the folders: /custom_components/homekit_controller inside /config, create a new file "init.py", copy and paste contents of the library: https://raw.githubusercontent.com/home-assistant/home-assistant/dev/homeassistant/components/homekit_controller/__init__.py and change the line 42 from "REQUEST_TIMEOUT = 5" to "REQUEST_TIMEOUT = 60".

I tried the same but it won’t add it I’m afraid my output is:


Error handling message: {'type': 'call_service', 'domain': 'configurator', 'service': 'configure', 'service_data': {'configure_id': '140101190929488-1', 'fields': {'code': 'xxx-xx-xxx'}}, 'id': 17}
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/websocket_api/decorators.py", line 16, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/app/homeassistant/components/websocket_api/commands.py", line 148, in handle_call_service
    connection.context(msg))
  File "/usr/src/app/homeassistant/core.py", line 1121, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/app/homeassistant/core.py", line 1143, in _execute_service
    await handler.func(service_call)
  File "/usr/src/app/homeassistant/components/configurator.py", line 221, in async_handle_service_call
    call.data.get(ATTR_FIELDS, {}))
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/homekit_controller/__init__.py", line 192, in device_config_callback
    pairing_id)
  File "/config/deps/lib/python3.6/site-packages/homekit/protocol.py", line 69, in perform_pair_setup
    connection.request('POST', '/pair-setup', request_tlv, headers)
  File "/usr/local/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/src/app/homeassistant/components/homekit_controller/__init__.py", line 64, in homekit_http_send
    self.send(msg)
  File "/usr/local/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/local/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/local/lib/python3.6/socket.py", line 724, in create_connection
    raise err
  File "/usr/local/lib/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
socket.timeout: timed out
aptonline commented 5 years ago

Also if I name the init.py file as _init_.py I receive the following:

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/sensor/waze_travel_time.py", line 74, in <lambda>
    EVENT_HOMEASSISTANT_START, lambda _: sensor.update())
  File "/usr/src/app/homeassistant/components/sensor/waze_travel_time.py", line 204, in update
    routes = params.calc_all_routes_info(real_time=self._realtime)
  File "/usr/local/lib/python3.6/site-packages/WazeRouteCalculator/WazeRouteCalculator.py", line 145, in calc_all_routes_info
    routes = self.get_route(npaths, time_delta)
  File "/usr/local/lib/python3.6/site-packages/WazeRouteCalculator/WazeRouteCalculator.py", line 95, in get_route
    response_json = response.json()
  File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/simplejson/__init__.py", line 518, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
bncbnc83 commented 5 years ago

I tryed to extend the timeout and it worked. But i get a new error

Sun Jan 06 2019 23:13:03 GMT+0100 (Centraleuropæisk normaltid)

homekit_controller: Error on device update!
Traceback (most recent call last):
  File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File “/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/init.py”, line 251, in update
    data = self._accessory.get_json(’/accessories’)
AttributeError: ‘HKDevice’ object has no attribute ‘get_json’
bncbnc83 commented 5 years ago

After updating HASS its working... but after a couple of hours it stops responding with this error:


2019-01-11 17:03:08 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out

Then after i reboot HASS it works again for some time ?

Jc2k commented 5 years ago

Woo - it looks like my pull request helped a little bit. I've been working on homekit_controller to get it ready for bluetooth homekit devices and so the HTTP requests that were failing for you are now hidden in the homekit library hass uses (http://github.com/jlusiardi/homekit_python). I guess the implementation has changed a little bit and the timeout is now a bit longer than it used to be.

Can I just check a few assumptions:

How comfortable are you making changes to the code yourself?

One limitation I think I can see with the current code (I need to dig in some more) is i'm not sure how it would handle things if the IP of the homekit device got a different IP address from DHCP whilst HASS was running. In that scenario, restarting HASS and only hass would fix it. Are you able to set up a static DHCP lease for this device to rule that out?

I've ordered a Koogeek LS1 to see if I can debug some of the Koogeek issues on this github, but i'm in the middle of quite a few other HASS/homekit changes so it might take me a bit to get at this properly.

bncbnc83 commented 5 years ago

Hello Jc2k. thank you for your reply :-)

How often have you had to restart it so far? Many times a day. Dont know how many. but i think it only works 1-3 of hours before it needs reboot.

Do you just restart HASS or do you restart the homekit device as well? I only need to restart HASS Do you see multiple tracebacks like this or does it stop entirely after the first traceback? It keeps going to next reboot

When it breaks, do you see an error like this about once a minute or are they spread out over a random period of time? Evert minut.


Update for switch.p1eu_4 fails
09.52 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_3 fails
09.52 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu fails
09.52 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_2 fails
09.52 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu fails
09.52 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_3 fails
09.52 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_2 fails
09.52 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_4 fails
09.52 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_4 fails
09.51 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_2 fails
09.51 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu fails
09.51 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_3 fails
09.51 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_3 fails
09.51 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_2 fails
09.51 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_4 fails
09.51 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu fails
09.51 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_2 fails
09.50 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu fails
09.50 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_3 fails
09.50 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_4 fails
09.50 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_2 fails
09.50 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_4 fails
09.50 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu fails
09.50 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_3 fails
09.50 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu fails
09.49 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)

Sat Jan 12 2019 09:52:41 GMT+0100 (Centraleuropæisk normaltid)

Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 88, in _handle_request
    self.sock.send(len_bytes + ciper_and_mac[0] + ciper_and_mac[1])
BrokenPipeError: [Errno 32] Broken pipe

How comfortable are you making changes to the code yourself? Dont think it would be a problem :-) Just want it working :-D. So if you tell me where and i will be happy to test and give info back.

They already running with static dhcp ip

If you can find the time i will be very happy. but im glad just to know someone is looking in to it :-)

bncbnc83 commented 5 years ago

I also get this error


Mon Jan 14 2019 21:21:54 GMT+0100 (Centraleuropæisk normaltid)

Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray

Jc2k commented 5 years ago

Thanks for the update @bncbnc83. This 2nd error is tricky. I know that the decryption code sometimes returns False (e.g. if messages are decrypted in the wrong order). So it's like that code isn't handling a failed decryption properly. I've raised a bug for that here, but I think the timeout is the issue to concentrate on first. I have a few ideas - i'll try to put together some more tests to try as soon as i can.

Jc2k commented 5 years ago

@bncbnc83 I've put together a PR for the timeout issue. It closes the secure session and opens another if the current one fails. This should stop it failing entirely like it is doing now, if a single update fails the next one should reconnect. But there might be intermittent connection dropouts still that it recovers from.

I haven't tested it yet (away from my HK devices) but the tests still pass. If you want to try it you should be able to install it direct from my github with something like:

pip install https://github.com/Jc2k/homekit_python/archive/90_recover_from_tcp_failure.zip
bncbnc83 commented 5 years ago

@Jc2k thank you for your work:-) I tryed to update now i get new errors (or maybe its the same errors...i dont know :-) )


homekit_controller: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out
______________________________
Tue Jan 15 2019 21:56:08 GMT+0100 (Centraleuropæisk normaltid)

Update for switch.p1eu_2 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out
_______________________
Update for switch.p1eu_2 fails
21.57 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_2 fails
21.56 deps/lib/python3.6/site-packages/homekit/http_impl/response.py (ERROR)
Update for switch.p1eu_2 fails
21.56 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
Update for switch.p1eu_2 fails
21.56 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
homekit_controller: Error on device update!
21.54 deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)
______________________________
Update for switch.p1eu_2 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray

Jc2k commented 5 years ago

Hmmm I’m not sure if the upgrade worked - can you try again but pass —upgrade to pip? (2 dashes, my phone keeps turning it into one). If it still doesn’t work do a pip uninstall homekit before the install.

bncbnc83 commented 5 years ago

Hello :-) tryed again. But i think it still fail.

here is what i did(Dont know if its the right way) My server is running on my server (Hyper-V) i connect to the server use user root type login to get to shell Type docker exec -it homeassistant /bin/bash type pip install https://github.com/Jc2k/homekit_python/archive/90_recover_from_tcp_failure.zip also tryed uninstall before. and also tryed to reboot the docker homeassistant afterwards am i doing something wrong ?

dave-castle commented 5 years ago

Hi folks,

I also got some issues with the koogeek items (3x switch.p1eu & 1x switch.kh02cn). After some time the items may lose the connection or whatever. They are unreachable over the frontend, the switch immediately turn from on to off or reversed after operated. They appear as ON in the Home app, but won't react to any action. If I restart HASS (0.85 via Synology Docker) it's working for a period of time, but then still runs in the same error.

Update for switch.p1eu_2 fails
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
Jc2k commented 5 years ago

Hey @bncbnc83 - when you install from my PR you should see something like:

pip install --upgrade https://github.com/Jc2k/homekit_python/archive/90_recover_from_tcp_failure.zip
Collecting https://github.com/Jc2k/homekit_python/archive/90_recover_from_tcp_failure.zip
  Downloading https://github.com/Jc2k/homekit_python/archive/90_recover_from_tcp_failure.zip
     / 1.4MB 11.9MB/s
Requirement already up-to-date: ed25519 in ./venv/lib/python3.6/site-packages (from homekit==0.12.0)
Requirement already up-to-date: gmpy2 in ./venv/lib/python3.6/site-packages (from homekit==0.12.0)
Requirement already up-to-date: hkdf in ./venv/lib/python3.6/site-packages (from homekit==0.12.0)
Requirement already up-to-date: py25519 in ./venv/lib/python3.6/site-packages (from homekit==0.12.0)
Requirement already up-to-date: zeroconf in ./venv/lib/python3.6/site-packages (from homekit==0.12.0)
Requirement already up-to-date: cffi-utils in ./venv/lib/python3.6/site-packages (from py25519->homekit==0.12.0)
Requirement already up-to-date: ifaddr in ./venv/lib/python3.6/site-packages (from zeroconf->homekit==0.12.0)
Requirement already up-to-date: cffi>=1.0.0 in ./venv/lib/python3.6/site-packages (from cffi-utils->py25519->homekit==0.12.0)
Requirement already up-to-date: pycparser in ./venv/lib/python3.6/site-packages (from cffi>=1.0.0->cffi-utils->py25519->homekit==0.12.0)
Installing collected packages: homekit
  Found existing installation: homekit 0.12.0
    Uninstalling homekit-0.12.0:
      Successfully uninstalled homekit-0.12.0
  Running setup.py install for homekit ... done
Successfully installed homekit-0.12.0

In paricular, did it say it uninstalled it and reinstalled it?

With the first command I gave you it probably looked like it did something but:

  Requirement already satisfied (use --upgrade to upgrade): homekit==0.12.0 from https://github.com/J...

if it says that it didn't actually change anything!

If i use the command I gave in this comment and restart HASS then I deliberately break my connection I now get this:

2019-01-16 12:25:46 ERROR (MainThread) [homeassistant.helpers.entity] Update for light.ls1 fails
Traceback (most recent call last):
  File "/home/john/homekit_python/homekit/http_impl/secure_http.py", line 92, in _handle_request
    return self._read_response()
  File "/home/john/homekit_python/homekit/http_impl/secure_http.py", line 136, in _read_response
    data = self.sock.recv(exp_len)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/john/home-assistant/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/home/john/home-assistant/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/john/home-assistant/homeassistant/components/homekit_controller/__init__.py", line 248, in update
    new_values_dict = pairing.get_characteristics(self._chars_to_poll)
  File "/home/john/homekit_python/homekit/controller.py", line 375, in get_characteristics
    response = self.session.get(url)
  File "/home/john/homekit_python/homekit/controller.py", line 614, in get
    return self.sec_http.get(url)
  File "/home/john/homekit_python/homekit/http_impl/secure_http.py", line 66, in get
    return self._handle_request(data)
  File "/home/john/homekit_python/homekit/http_impl/secure_http.py", line 94, in _handle_request
    raise exceptions.AccessoryDisconnectedError(str(e))
homekit.exceptions.AccessoryDisconnectedError: [Errno 104] Connection reset by peer

Not quite the same as a timeout but is an idea of what i'm expecting to happen in your case.

Although the error is still logged it recovers from this (not like before where it was broken until a restart).

To be clear - there will still be an exception logged, but this branch should mean it recovers from the failure to some degree.

Jc2k commented 5 years ago

@dave-castle hi! thanks for reaching out. yes, it looks like you are hitting the same issue. the PR i'm talking about should stop the failure from requiring a HA restart. But I could do with feedback from a HA user first. If you are comfortable making changes to a running container then you can do something like:

$ docker exec -it yourcontainer bash
# pip install --upgrade https://github.com/Jc2k/homekit_python/archive/90_recover_from_tcp_failure.zip

If it works you should see:

Installing collected packages: homekit
  Found existing installation: homekit 0.12.0
    Uninstalling homekit-0.12.0:
      Successfully uninstalled homekit-0.12.0
Successfully installed homekit-0.12.0

Then restart your container and let me know how you get on. You will still see some timeouts - but they should no longer be fatal.

bncbnc83 commented 5 years ago

@Jc2k i think that did the trick :-D 👍 it keeps working right now... but i still get errors


Press the button to load the full Home Assistant log.

2019-01-16 22:43:43 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out
2019-01-16 22:44:13 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out
2019-01-16 22:44:43 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
2019-01-16 22:45:14 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
2019-01-16 22:45:45 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out
2019-01-16 22:46:15 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
2019-01-16 22:46:46 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
2019-01-16 22:47:17 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out
2019-01-16 22:47:48 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
2019-01-16 22:48:19 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out
2019-01-16 22:48:50 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
2019-01-16 22:49:21 ERROR (MainThread) [homeassistant.helpers.entity] Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 154, in _read_response
    response.parse(decrypted)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray

Afterwards i tryed quick turning on/off a couple of times then it stops responding and i had to reboot. (not included in the pasted log)

But for now it respons when turn on/off as you normal would use it i will give an update tomorrow about if it keeps working after some hours

bncbnc83 commented 5 years ago

@Jc2k no still the same 😔

dave-castle commented 5 years ago

Same here 😢

Even the update to 0.85.1 brought no improvement

Jc2k commented 5 years ago

In the logs posted you are still not seeing a AccessoryDisconnectedError. That’s unexpected. You are seeing socket.timeout, which is a subclass of OSError since python 3.3, which the new code is supposed to be catching :/ ill have another look..

bncbnc83 commented 5 years ago

@Jc2k thank you :-) 👍

Jc2k commented 5 years ago

@bncbnc83 Ok have reproduced a related error here, amended my PR and am seeing if it recurs. Hope to give you an updated download to try.. soonish. But still haven't seen a socket.timeout in my environment :(.

bncbnc83 commented 5 years ago

@Jc2k its not hard to get here :-D Is there any info i can give you to help ?

Btw if i type pip uninstall homekit and reboots its still adds and give the samme errors ?


Update for switch.p1eu_2 fails 4:23 PM deps/lib/python3.6/site-packages/homekit/http_impl/response.py (ERROR) Update for switch.p1eu_3 fails 4:23 PM deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR) Update for switch.p1eu_2 fails 4:23 PM deps/lib/python3.6/site-packages/homekit/http_impl/response.py (ERROR) Update for switch.p1eu_2 fails 4:22 PM deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR) Update for switch.p1eu_2 fails 4:22 PM deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py (ERROR)


How can it still "Work" after removing homekit ? if type pip uninstall homekit it say its not installed ?

Jc2k commented 5 years ago

So the deps/ folder contains pip packages it installed itself, but normal pip doesn't know about them. Even if you did delete it, it would reinstall the 'stable' released version again. I don't know which folder has precedence. It's possible this auto-installed one is taking precedence and thats the problem. You could do the pip install and then rm deps/lib/python3.6/site-packages/homekit and see if that helps?

bncbnc83 commented 5 years ago

I think it works after i removed the other homekit folder :-D 👍 No errors yet :-D

Jc2k commented 5 years ago

You should still see at least one error if its hit the timeout! It should just stop spamming them and recover from it... Need to do a change against homeassistant to get it fixed entirely.

bncbnc83 commented 5 years ago

@Jc2k 👍 I will update later to with info about if it keeps working :-)

EDIT: Just a early update - its still working but i got some errors


Update for switch.p1eu_3 fails
4:51 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
4:51 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
4:49 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
4:48 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
4:47 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
4:47 PM components/homekit_controller/__init__.py (ERROR)
_________________________________________
Thu Jan 17 2019 16:47:18 GMT+0100 (Centraleuropæisk normaltid)

Update for switch.p1eu_3 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 274, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 614, in get
    return self.sec_http.get(url)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 66, in get
    return self._handle_request(data)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 92, in _handle_request
    return self._read_response()
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 159, in _read_response
    response.parse(decrypted)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
__________________________________________
Thu Jan 17 2019 16:47:44 GMT+0100 (Centraleuropæisk normaltid)

Update for switch.p1eu_3 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 92, in _handle_request
    return self._read_response()
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 136, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 274, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 614, in get
    return self.sec_http.get(url)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 66, in get
    return self._handle_request(data)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 94, in _handle_request
    raise exceptions.AccessoryDisconnectedError(str(e))
homekit.exceptions.AccessoryDisconnectedError: timed out

dave-castle commented 5 years ago

It's weird, but automations are workin' without problems, just switching on/off in Home or in the HASS frontend are broken 🤔

Jc2k commented 5 years ago

Still not seen a timeout over here! My instance has been running since a couple of hours before you updated as well. Wonder what the underlying reason is...

Anyway - this is great. I need to get this fix into a homekit release before I can do the corresponding homeassistant bit. Will update my PR with your success.

Jc2k commented 5 years ago

@dave-castle that is weird 🤔 are you seeing the same errors as before? do you see any errors in the logs when automations run?

bncbnc83 commented 5 years ago

Mine keeps working after upgrading the fixed homekit and removed homekit from deps. Now i also got the Peer timeout + some others (But it keeps working :-DDD 👍 )


Thu Jan 17 2019 17:50:54 GMT+0100 (Centraleuropæisk normaltid)

Update for switch.p1eu_4 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 92, in _handle_request
    return self._read_response()
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 136, in _read_response
    data = self.sock.recv(exp_len)
ConnectionResetError: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 274, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 614, in get
    return self.sec_http.get(url)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 66, in get
    return self._handle_request(data)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 94, in _handle_request
    raise exceptions.AccessoryDisconnectedError(str(e))
homekit.exceptions.AccessoryDisconnectedError: [Errno 104] Connection reset by peer
_______________________________________

Log Details (ERROR)
Thu Jan 17 2019 17:57:02 GMT+0100 (Centraleuropæisk normaltid)

Update for switch.p1eu_3 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 92, in _handle_request
    return self._read_response()
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 136, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 274, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 614, in get
    return self.sec_http.get(url)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 66, in get
    return self._handle_request(data)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 94, in _handle_request
    raise exceptions.AccessoryDisconnectedError(str(e))
homekit.exceptions.AccessoryDisconnectedError: timed out
______________________________________
Thu Jan 17 2019 17:47:49 GMT+0100 (Centraleuropæisk normaltid)

Update for switch.p1eu_3 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 274, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 614, in get
    return self.sec_http.get(url)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 66, in get
    return self._handle_request(data)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 92, in _handle_request
    return self._read_response()
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 159, in _read_response
    response.parse(decrypted)
  File "/usr/local/lib/python3.6/site-packages/homekit/http_impl/response.py", line 38, in parse
    self._raw_response += part
TypeError: can't concat bool to bytearray
_______________________
Update for switch.p1eu_3 fails
5:57 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:55 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:52 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu fails
5:51 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_4 fails
5:50 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:50 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_2 fails
5:50 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:49 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:49 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:48 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:47 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:47 PM components/homekit_controller/__init__.py (ERROR)
Update of switch.p1eu_3 is taking over 10 seconds
5:47 PM util/async_.py (WARNING)
Update for switch.p1eu_3 fails
5:46 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:44 PM components/homekit_controller/__init__.py (ERROR)
Update of switch.p1eu_3 is taking over 10 seconds
5:42 PM util/async_.py (WARNING)
Update for switch.p1eu_3 fails
5:42 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:40 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:40 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:39 PM components/homekit_controller/__init__.py (ERROR)
Update of switch.p1eu_3 is taking over 10 seconds
5:39 PM util/async_.py (WARNING)
Update for switch.p1eu_3 fails
5:39 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:37 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:35 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:34 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:33 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:32 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:31 PM components/homekit_controller/__init__.py (ERROR)
Update of switch.p1eu_3 is taking over 10 seconds
5:31 PM util/async_.py (WARNING)
Update for switch.p1eu_3 fails
5:30 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:26 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:24 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:23 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:22 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:21 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:20 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:20 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:18 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:16 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:15 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:11 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:10 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:06 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:04 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:03 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:02 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:01 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_4 fails
5:00 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
5:00 PM components/homekit_controller/__init__.py (ERROR)
Update for switch.p1eu_3 fails
4:59 PM components/homekit_controller/__init__.py (ERROR)

Dont know if it give more errors when i turn on/off

@Jc2k your my new hero ;-)

dave-castle commented 5 years ago

I'll check it later within my Docker environment! Is it going to be fixed in the next HASS release?

dave-castle commented 5 years ago

@dave-castle that is weird 🤔 are you seeing the same errors as before? do you see any errors in the logs when automations run?

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/app/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/homekit_controller/__init__.py", line 197, in update
    data = pairing.list_accessories_and_characteristics()
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 273, in list_accessories_and_characteristics
    response = self.session.get('/accessories')
  File "/config/deps/lib/python3.6/site-packages/homekit/controller.py", line 573, in get
    return self.sec_http.get(url)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 65, in get
    return self._handle_request(data)
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 89, in _handle_request
    return self._read_response()
  File "/config/deps/lib/python3.6/site-packages/homekit/http_impl/secure_http.py", line 131, in _read_response
    data = self.sock.recv(exp_len)
socket.timeout: timed out
Jc2k commented 5 years ago

Can't promise when it will be fixed - I'm not a HA maintainer or a homekit_python maintainer and I have to get PR's accepted into both to properly address this. But it looks like i'm on the right track and I have had other PR's accepted into both projects already so its not impossible.

bncbnc83 commented 5 years ago

@dave-castle looks like your still are running from deps

bncbnc83 commented 5 years ago

@Jc2k Still working without reboots 👍 :-)

Jc2k commented 5 years ago

@bncbnc83 this is great news!

This part of the fix just got rolled into a new release of homekit. It's got a few other changes rolled into it so i'd appreciate it if you could switch to it and give me some feedback.

It should be enough to do:

pip install homekit==0.12.2

Make sure you don't do --upgrade this time.

I'll start putting together the corresponding HA change today/tomorrow.

dave-castle commented 5 years ago

@Jc2k

Awesome, really appreciate your work!!! So I’ll wait for official HA fix.

Thanks!!!

bncbnc83 commented 5 years ago

@Jc2k Hello :-) Now i get


Tue Jan 22 2019 13:19:52 GMT+0100 (Centraleuropæisk normaltid)

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 290, in discovery_dispatch
    device = HKDevice(hass, host, port, model, hkid, config_num, config)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 91, in __init__
    self.accessory_setup()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 104, in accessory_setup
    data = self.pairing.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 272, in list_accessories_and_characteristics
    self.session = Session(self.pairing_data)
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 604, in __init__
    c2a_key, a2c_key = get_session_keys(conn, pairing_data)
  File "/usr/local/lib/python3.6/site-packages/homekit/protocol/__init__.py", line 247, in get_session_keys
    ios_key = x25519.X25519PrivateKey.generate()
  File "/usr/local/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py", line 39, in generate
    _Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM
cryptography.exceptions.UnsupportedAlgorithm: X25519 is not supported by this version of OpenSSL.

Jc2k commented 5 years ago

Ick. 1 step forward 2 step back.

Upstream homekit is using cryptography now. That was to run on a wider range of OS's and to let me add tests to HA to stop future regressions. This is a change from py25519 that hasn't had a release in years, won't install at all on some OS's.. It's a bit of a pain dependency for adding tests to HA too. Now if you install cryptography with wheel support it has a version of OpenSSL built in that supports X25519. And I double checked, HA won't start unless it has cryptography==2.3.1. So you should definitely have the right version, and that version works on my linux vms, macs, the HA docker container, even a raspberry pi from 2011. The only thing I can think of is that it didn't use a wheel and instead compiled against your system openssl, and you are on a distro old enough for that to be a problem. If its that then reinstalling it as a wheel will fix it.

What OS are you installing on? Is this the Docker container or bare metal? Arm or Intel/AMD? Can you give me the output of pip freeze | grep cryptography. And also maybe pip freeze | grep wheel.

bncbnc83 commented 5 years ago

@Jc2k Was running in HyperV - Hassio VHDX (beta) image Now i changed it to Hyper-v - ubuntu and running it from docker still same error


Log Details (ERROR)
Tue Jan 22 2019 22:06:56 GMT+0100 (Centraleuropæisk normaltid)

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 290, in discovery_dispatch
    device = HKDevice(hass, host, port, model, hkid, config_num, config)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 91, in __init__
    self.accessory_setup()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/homekit_controller/__init__.py", line 104, in accessory_setup
    data = self.pairing.list_accessories_and_characteristics()
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 272, in list_accessories_and_characteristics
    self.session = Session(self.pairing_data)
  File "/usr/local/lib/python3.6/site-packages/homekit/controller.py", line 604, in __init__
    c2a_key, a2c_key = get_session_keys(conn, pairing_data)
  File "/usr/local/lib/python3.6/site-packages/homekit/protocol/__init__.py", line 247, in get_session_keys
    ios_key = x25519.X25519PrivateKey.generate()
  File "/usr/local/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py", line 39, in generate
    _Reasons.UNSUPPORTED_EXCHANGE_ALGORITHM
cryptography.exceptions.UnsupportedAlgorithm: X25519 is not supported by this version of OpenSSL.

This is what i get from your commands


cryptography==2.3.1 And nothing from wheel¨


Jc2k commented 5 years ago

Weird - the upstream Docker image works for me. The line of code that fails for you working on the official Docker image:

$ docker run --rm -it homeassistant/home-assistant python
Python 3.6.8 (default, Jan  9 2019, 04:19:48) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography.hazmat.primitives.asymmetric import x25519
>>> x25519.X25519PrivateKey.generate().public_key().public_bytes()
b'K\x98\n\xb1\xa3F\x1d\x91v.\xe3}\xa1>\xc7\xdd:C\xa7\xab\xfa\x02<\xc4R\rv\x84o~Y6'

It's also working on an Ubuntu 18.04 image:

$ python3 -m venv venv-bncbnc83
$ source venv-bncbnc83/bin/activate
$ pip install --no-cache cryptography==2.3.1
Collecting cryptography==2.3.1
  Downloading https://files.pythonhosted.org/packages/59/32/92cade62c645756a83598edf56289e9b19aae5370642a7ce690cd06bc72f/cryptography-2.3.1-cp34-abi3-manylinux1_x86_64.whl (2.1MB)
    100% |████████████████████████████████| 2.1MB 3.5MB/s 
Collecting idna>=2.1 (from cryptography==2.3.1)
  Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
    100% |████████████████████████████████| 61kB 3.3MB/s 
Collecting six>=1.4.1 (from cryptography==2.3.1)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting cffi!=1.11.3,>=1.7 (from cryptography==2.3.1)
  Downloading https://files.pythonhosted.org/packages/6d/c0/47db8f624f3e4e2f3f27be03a93379d1ba16a1450a7b1aacfa0366e2c0dd/cffi-1.11.5-cp36-cp36m-manylinux1_x86_64.whl (421kB)
    100% |████████████████████████████████| 430kB 3.7MB/s 
Collecting asn1crypto>=0.21.0 (from cryptography==2.3.1)
  Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
    100% |████████████████████████████████| 102kB 3.5MB/s 
Collecting pycparser (from cffi!=1.11.3,>=1.7->cryptography==2.3.1)
  Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz (158kB)
    100% |████████████████████████████████| 163kB 3.1MB/s 
Installing collected packages: idna, six, pycparser, cffi, asn1crypto, cryptography
  Running setup.py install for pycparser ... done
Successfully installed asn1crypto-0.24.0 cffi-1.11.5 cryptography-2.3.1 idna-2.8 pycparser-2.19 six-1.12.0
$ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography.hazmat.primitives.asymmetric import x25519
>>> x25519.X25519PrivateKey.generate().public_key().public_bytes()
b'\xbd\x0c\x9aJ\x1fv\xf1\x8b\x0e\xc7\xbch\x8a\x056N\x9aY\xf7,st\x96\xe9A\xe4\xcb\xcex\x07W*'
>>> 

Tried something similar on Debian Stretch and it worked there too.

What do you get if you do this?

# ls /usr/local/lib/python3.6/site-packages/cryptography*
# ls /usr/local/lib/python3.6/site-packages/cryptography/hazmat/bindings/

And what is the output if you do this:

pip uninstall cryptography
pip install cryptography==2.3.1

(And does it work after doing that)

Oh and hey - if you put triple back ticks around your output GitHub will format it nicer:

``` Like this ```

bncbnc83 commented 5 years ago

strange :-) Btw its ubuntu 18.04 i run docker on

bash-4.4# ls /usr/local/lib/python3.6/site-packages/cryptography*
/usr/local/lib/python3.6/site-packages/cryptography:
__about__.py   __init__.py    __pycache__    exceptions.py  fernet.py      hazmat         utils.py       x509

/usr/local/lib/python3.6/site-packages/cryptography-2.3.1-py3.6.egg-info:
PKG-INFO              SOURCES.txt           dependency_links.txt  installed-files.txt   not-zip-safe          requires.txt          top_level.txt
bash-4.4# ls /usr/local/lib/python3.6/site-packages/cryptography/hazmat/bindings/
__init__.py             __pycache__             _constant_time.abi3.so  _openssl.abi3.so        _padding.abi3.so        openssl

Now i hit errors after reinstalling

  Failed building wheel for cryptography
  Running setup.py clean for cryptography
Failed to build cryptography
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4jbcfj5a/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-0y_dtf3q/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-4jbcfj5a/cryptography/

Full log

bash-4.4# pip uninstall cryptography
Uninstalling cryptography-2.3.1:
  Would remove:
    /usr/local/lib/python3.6/site-packages/cryptography-2.3.1-py3.6.egg-info
    /usr/local/lib/python3.6/site-packages/cryptography/*
Proceed (y/n)? y
  Successfully uninstalled cryptography-2.3.1
You are using pip version 18.0, however version 19.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
bash-4.4# pip install cryptography==2.3.1
Collecting cryptography==2.3.1
  Downloading https://files.pythonhosted.org/packages/22/21/233e38f74188db94e8451ef6385754a98f3cad9b59bedf3a8e8b14988be4/cryptography-2.3.1.tar.gz (449kB)
    100% |████████████████████████████████| 450kB 7.7MB/s
Requirement already satisfied: idna>=2.1 in /usr/local/lib/python3.6/site-packages (from cryptography==2.3.1) (2.8)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/local/lib/python3.6/site-packages (from cryptography==2.3.1) (0.24.0)
Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python3.6/site-packages (from cryptography==2.3.1) (1.12.0)
Requirement already satisfied: cffi!=1.11.3,>=1.7 in /usr/local/lib/python3.6/site-packages (from cryptography==2.3.1) (1.11.5)
Requirement already satisfied: pycparser in /usr/local/lib/python3.6/site-packages (from cffi!=1.11.3,>=1.7->cryptography==2.3.1) (2.19)
Building wheels for collected packages: cryptography
  Running setup.py bdist_wheel for cryptography ... error
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4jbcfj5a/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-buy8z8vh --python-tag cp36:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/cryptography
  copying src/cryptography/__about__.py -> build/lib.linux-x86_64-3.6/cryptography
  copying src/cryptography/utils.py -> build/lib.linux-x86_64-3.6/cryptography
  copying src/cryptography/exceptions.py -> build/lib.linux-x86_64-3.6/cryptography
  copying src/cryptography/fernet.py -> build/lib.linux-x86_64-3.6/cryptography
  copying src/cryptography/__init__.py -> build/lib.linux-x86_64-3.6/cryptography
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat
  copying src/cryptography/hazmat/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat
  creating build/lib.linux-x86_64-3.6/cryptography/x509
  copying src/cryptography/x509/base.py -> build/lib.linux-x86_64-3.6/cryptography/x509
  copying src/cryptography/x509/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/x509
  copying src/cryptography/x509/oid.py -> build/lib.linux-x86_64-3.6/cryptography/x509
  copying src/cryptography/x509/certificate_transparency.py -> build/lib.linux-x86_64-3.6/cryptography/x509
  copying src/cryptography/x509/name.py -> build/lib.linux-x86_64-3.6/cryptography/x509
  copying src/cryptography/x509/general_name.py -> build/lib.linux-x86_64-3.6/cryptography/x509
  copying src/cryptography/x509/extensions.py -> build/lib.linux-x86_64-3.6/cryptography/x509
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings
  copying src/cryptography/hazmat/bindings/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/interfaces.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends
  copying src/cryptography/hazmat/backends/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/hashes.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/padding.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/constant_time.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/hmac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/mac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/serialization.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/keywrap.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  copying src/cryptography/hazmat/primitives/cmac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/_conditional.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings/openssl
  copying src/cryptography/hazmat/bindings/openssl/binding.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings/openssl
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/hashes.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/utils.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ciphers.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/aead.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/rsa.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x509.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/hmac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/x25519.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/encode_asn1.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/dsa.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/ec.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/dh.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/backend.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/decode_asn1.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  copying src/cryptography/hazmat/backends/openssl/cmac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/pbkdf2.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/kbkdf.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/hkdf.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/concatkdf.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/scrypt.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
  copying src/cryptography/hazmat/primitives/kdf/x963kdf.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/hotp.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/utils.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/totp.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
  copying src/cryptography/hazmat/primitives/twofactor/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/base.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/modes.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/aead.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
  copying src/cryptography/hazmat/primitives/ciphers/algorithms.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
  creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/utils.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/padding.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/rsa.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/x25519.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/dsa.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/ec.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  copying src/cryptography/hazmat/primitives/asymmetric/dh.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
  running egg_info
  writing src/cryptography.egg-info/PKG-INFO
  writing dependency_links to src/cryptography.egg-info/dependency_links.txt
  writing requirements to src/cryptography.egg-info/requires.txt
  writing top-level names to src/cryptography.egg-info/top_level.txt
  reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  no previously-included directories found matching 'docs/_build'
  warning: no previously-included files matching '*' found under directory 'vectors'
  writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
  running build_ext
  generating cffi module 'build/temp.linux-x86_64-3.6/_padding.c'
  creating build/temp.linux-x86_64-3.6
  generating cffi module 'build/temp.linux-x86_64-3.6/_constant_time.c'
  generating cffi module 'build/temp.linux-x86_64-3.6/_openssl.c'
  building '_openssl' extension
  creating build/temp.linux-x86_64-3.6/build
  creating build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.6m -c build/temp.linux-x86_64-3.6/_openssl.c -o build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/_openssl.o -Wconversion -Wno-error=sign-conversion
  unable to execute 'gcc': No such file or directory
  error: command 'gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for cryptography
  Running setup.py clean for cryptography
Failed to build cryptography
Installing collected packages: cryptography
  Running setup.py install for cryptography ... error
    Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4jbcfj5a/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-0y_dtf3q/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/cryptography
    copying src/cryptography/__about__.py -> build/lib.linux-x86_64-3.6/cryptography
    copying src/cryptography/utils.py -> build/lib.linux-x86_64-3.6/cryptography
    copying src/cryptography/exceptions.py -> build/lib.linux-x86_64-3.6/cryptography
    copying src/cryptography/fernet.py -> build/lib.linux-x86_64-3.6/cryptography
    copying src/cryptography/__init__.py -> build/lib.linux-x86_64-3.6/cryptography
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat
    copying src/cryptography/hazmat/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat
    creating build/lib.linux-x86_64-3.6/cryptography/x509
    copying src/cryptography/x509/base.py -> build/lib.linux-x86_64-3.6/cryptography/x509
    copying src/cryptography/x509/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/x509
    copying src/cryptography/x509/oid.py -> build/lib.linux-x86_64-3.6/cryptography/x509
    copying src/cryptography/x509/certificate_transparency.py -> build/lib.linux-x86_64-3.6/cryptography/x509
    copying src/cryptography/x509/name.py -> build/lib.linux-x86_64-3.6/cryptography/x509
    copying src/cryptography/x509/general_name.py -> build/lib.linux-x86_64-3.6/cryptography/x509
    copying src/cryptography/x509/extensions.py -> build/lib.linux-x86_64-3.6/cryptography/x509
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings
    copying src/cryptography/hazmat/bindings/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/backends
    copying src/cryptography/hazmat/backends/interfaces.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends
    copying src/cryptography/hazmat/backends/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/hashes.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/padding.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/constant_time.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/hmac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/mac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/serialization.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/keywrap.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    copying src/cryptography/hazmat/primitives/cmac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings/openssl
    copying src/cryptography/hazmat/bindings/openssl/_conditional.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings/openssl
    copying src/cryptography/hazmat/bindings/openssl/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings/openssl
    copying src/cryptography/hazmat/bindings/openssl/binding.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/bindings/openssl
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/hashes.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/utils.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/ciphers.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/aead.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/rsa.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/x509.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/hmac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/x25519.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/encode_asn1.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/dsa.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/ec.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/dh.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/backend.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/decode_asn1.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    copying src/cryptography/hazmat/backends/openssl/cmac.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/backends/openssl
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
    copying src/cryptography/hazmat/primitives/kdf/pbkdf2.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
    copying src/cryptography/hazmat/primitives/kdf/kbkdf.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
    copying src/cryptography/hazmat/primitives/kdf/hkdf.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
    copying src/cryptography/hazmat/primitives/kdf/concatkdf.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
    copying src/cryptography/hazmat/primitives/kdf/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
    copying src/cryptography/hazmat/primitives/kdf/scrypt.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
    copying src/cryptography/hazmat/primitives/kdf/x963kdf.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/kdf
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
    copying src/cryptography/hazmat/primitives/twofactor/hotp.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
    copying src/cryptography/hazmat/primitives/twofactor/utils.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
    copying src/cryptography/hazmat/primitives/twofactor/totp.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
    copying src/cryptography/hazmat/primitives/twofactor/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/twofactor
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
    copying src/cryptography/hazmat/primitives/ciphers/base.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
    copying src/cryptography/hazmat/primitives/ciphers/modes.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
    copying src/cryptography/hazmat/primitives/ciphers/aead.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
    copying src/cryptography/hazmat/primitives/ciphers/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
    copying src/cryptography/hazmat/primitives/ciphers/algorithms.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/ciphers
    creating build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    copying src/cryptography/hazmat/primitives/asymmetric/utils.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    copying src/cryptography/hazmat/primitives/asymmetric/padding.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    copying src/cryptography/hazmat/primitives/asymmetric/rsa.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    copying src/cryptography/hazmat/primitives/asymmetric/x25519.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    copying src/cryptography/hazmat/primitives/asymmetric/dsa.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    copying src/cryptography/hazmat/primitives/asymmetric/__init__.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    copying src/cryptography/hazmat/primitives/asymmetric/ec.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    copying src/cryptography/hazmat/primitives/asymmetric/dh.py -> build/lib.linux-x86_64-3.6/cryptography/hazmat/primitives/asymmetric
    running egg_info
    writing src/cryptography.egg-info/PKG-INFO
    writing dependency_links to src/cryptography.egg-info/dependency_links.txt
    writing requirements to src/cryptography.egg-info/requires.txt
    writing top-level names to src/cryptography.egg-info/top_level.txt
    reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'docs/_build'
    warning: no previously-included files matching '*' found under directory 'vectors'
    writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
    running build_ext
    generating cffi module 'build/temp.linux-x86_64-3.6/_padding.c'
    creating build/temp.linux-x86_64-3.6
    generating cffi module 'build/temp.linux-x86_64-3.6/_constant_time.c'
    generating cffi module 'build/temp.linux-x86_64-3.6/_openssl.c'
    building '_openssl' extension
    creating build/temp.linux-x86_64-3.6/build
    creating build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6
    gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/local/include/python3.6m -c build/temp.linux-x86_64-3.6/_openssl.c -o build/temp.linux-x86_64-3.6/build/temp.linux-x86_64-3.6/_openssl.o -Wconversion -Wno-error=sign-conversion
    unable to execute 'gcc': No such file or directory
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-4jbcfj5a/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-0y_dtf3q/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-4jbcfj5a/cryptography/

Thanks for the tip...I learn new things every day :-D

Jc2k commented 5 years ago

Ah it looks like for whatever reason this environment doesn’t have wheel support.

Try ‘pip install wheel’ (haven’t figured out backticks on my phone) then the pip install cryptography command (with the version)

bncbnc83 commented 5 years ago

@Jc2k

bash-4.4# pip install wheel
Requirement already satisfied: wheel in /usr/local/lib/python3.6/site-packages (0.32.0)
You are using pip version 18.0, however version 19.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
bash-4.4# pip uninstall wheel
Uninstalling wheel-0.32.0:
  Would remove:
    /usr/local/bin/wheel
    /usr/local/lib/python3.6/site-packages/wheel-0.32.0.dist-info/*
    /usr/local/lib/python3.6/site-packages/wheel/*
Proceed (y/n)? y
  Successfully uninstalled wheel-0.32.0
You are using pip version 18.0, however version 19.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
bash-4.4# pip install wheel
Collecting wheel
  Using cached https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl
Installing collected packages: wheel
Successfully installed wheel-0.32.3

It still comes with same error after uninstall/install wheel

Jc2k commented 5 years ago

So after installing wheel if you install cryptography it still downloads a .tar.gz instead of a .whl?