Rest issues

I recently noticed the rest calls I make to a bunch of my internal servers are no longer working. Getting loads of errors in the log like:

2020-11-14 16:14:08 ERROR (MainThread) [homeassistant.components.sensor] rest: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 357, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
    await task
  File "/usr/src/homeassistant/homeassistant/components/rest/sensor.py", line 207, in async_update
    await self.rest.async_update()
  File "/usr/src/homeassistant/homeassistant/components/rest/data.py", line 52, in async_update
    response = await self._async_client.request(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1371, in request
    response = await self.send(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1406, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1444, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1476, in _send_handling_redirects
    response = await self._send_single_request(request, timeout)
  File "/usr/local/lib/python3.8/site-packages/httpx/_client.py", line 1502, in _send_single_request
    (status_code, headers, stream, ext,) = await transport.arequest(
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 208, in arequest
    connection = await self._get_connection_from_pool(origin)
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection_pool.py", line 248, in _get_connection_from_pool
    if connection.is_socket_readable():
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/connection.py", line 169, in is_socket_readable
    return self.connection is not None and self.connection.is_socket_readable()
  File "/usr/local/lib/python3.8/site-packages/httpcore/_async/http11.py", line 205, in is_socket_readable
    return self.socket.is_readable()
  File "/usr/local/lib/python3.8/site-packages/httpcore/_backends/asyncio.py", line 179, in is_readable
    return is_socket_readable(sock.fileno())
AttributeError: 'NoneType' object has no attribute 'fileno'

And even though I didn’t change anything in my rest calls I did check a few of them and they still return the expected results when using curl from the HA server.

Thoughts?

Think I need to scrap my use of Rest or my monitoring of my servers in general in this case. After multiple posts in the past and now about REST issues there haven’t been any replies so sounds like that isn’t super supported. That’s OK, just closing the loop or chapter on this way of using HA.

Without know what REST service you are calling, it’s impossible to guess what might be causing your errors. I’m reading error messages regarding redirects so perhaps the error is on the server-side. I have several REST sensors that have been working reliably for some time.

Same here but not sure if the specifics will help but can share what I can. I’ve changed nothing so happened after one of the HA updates. Basically an example call to one of my internal computers is:

- platform: rest
  resource: 'https://<ADDRESS>:9999/api/v1/queries/check_drivesize/commands/execute?drive=c'
  method: GET
  username: admin
  password: PASS>
  name: Encoder C Drive Used
  authentication: basic
  verify_ssl: false
  json_attributes_path: "$.[0].perf['c: used %']"
  json_attributes:
    - critical
    - maximum
    - minimum
    - warning
  value_template: "{{ value_json.lines[0].perf['c: used %'].value }}"
  unit_of_measurement: '%'

a similar one to get the C: drive space on the remote computer from curl on the HA box gives results as it always does so like:

curl --insecure -u curl --insecure -u admin: https://:9999/api/v1/queries/check_drivesize/commands/execute?drive=c

Using basically a tool called NSClient++ running on each computer and calling it’s statistical values for each computer. As mentioned, no changes on any of the 4 computers I was doing this with and after one of the recent updates, maybe 2 of them ago, it stopped working.

By the way for that example curl command I get back:

{"command":"check_drivesize","lines":[{"message":"OK All 1 drive(s) are ok","perf":{"c: used":{"critical":200.18935203552246,"maximum":222.43261337280273,"minimum":0.00000000000000000,"unit":"GB","value":48.464923858642578,"warning":177.94609069824219},"c: used %":{"critical":90.000000000000000,"maximum":100.00000000000000,"minimum":0.00000000000000000,"unit":"%","value":22.000000000000000,"warning":80.000000000000000}}}],"result":0}