Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE #43384

Closed
FransHalsjes opened this issue Nov 19, 2020 · 8 comments

Comments

@FransHalsjes
Copy link

The problem

The rest integration stops with the error:

Error fetching data: http://IP_ADDRESS/get-status failed with "can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE"

Logger: homeassistant.components.rest.data
Source: components/rest/data.py:63
Integration: rest (documentation, issues)

issuing the command in a browser gives back a proper JSON string. The rest call works

Environment

Version 0.118.0
Installation Type Home Assistant OS
Development false
Supervisor true
Docker true
Virtual Environment false
Python Version 3.8.6
Operating System Family Linux
Operating System Version 4.19.127-v8
CPU Architecture aarch64
Timezone Europe/Amsterdam
  • Home Assistant Core release with the issue:
  • Last working Home Assistant Core release (if known):
  • Operating environment (OS/Container/Supervised/Core):
  • Integration causing this issue:
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml

configuration.yaml

  • platform: rest
    name: achterpui_temperatuur
    resource: http://IP_ADDRESS/PASSWORD/get-status
    value_template: "{{ value_json.response.thermometers[0].te }}"
    unit_of_measurement: '°C'

Traceback/Error logs

Additional information

@elupus
Copy link
Contributor

elupus commented Nov 19, 2020

The issue is likely in upstream httpx library. Would you be able to try to reproduce this with pure python and the httpx library? It should be reported upstream very likely.

@FransHalsjes
Copy link
Author

Would love to do that, but have no idea how. Can you give some instructions?

@elupus
Copy link
Contributor

elupus commented Nov 20, 2020

Hmm. This looks very similar to: encode/httpx#96

@FransHalsjes
Copy link
Author

FransHalsjes commented Nov 20, 2020 via email

@probot-home-assistant
Copy link

rest documentation
rest source
(message by IssueLinks)

@FransHalsjes
Copy link
Author

FransHalsjes commented Nov 20, 2020 via email

@FransHalsjes
Copy link
Author

FransHalsjes commented Nov 23, 2020

problem solved!
I had 4 sensors, all querying the same server with the REST call above. That was too much for the server, so it gave the error above.
I restructured the configuration.yaml to have 1 REST call and then have the sensors created via a template:

# Home Wizard koppeling
- platform: rest
  name: hwdata
  json_attributes_path: "$.response"
  json_attributes:
    - thermometers
    - windmeters
    - rainmeters
  resource: http://IP_ADDRESS/PASWORD/get-status
  value_template: OK
- platform: template
  sensors:
    achterpui_temperatuur:
      friendly_name: "achterpui_temperatuur"
      value_template: "{{ state_attr('sensor.hwdata','thermometers')[0].te }}"
      unit_of_measurement: '°C'
    windsnelheid:
      friendly_name: "windsnelheid"
      value_template: "{{ state_attr('sensor.hwdata','windmeters')[0].ws }}"
      unit_of_measurement: 'km/h'      
    terrasrand_temperatuur:
      friendly_name: "terrasrand_temperatuur"
      value_template: "{{ state_attr('sensor.hwdata','windmeters')[0].te }}"
      unit_of_measurement: '°C'
    windrichting:
      friendly_name: "windrichting"
      value_template: "{{ state_attr('sensor.hwdata','windmeters')[0].dir.split (' ')[1] }}"
      unit_of_measurement: 'graden'
    regenval:
      friendly_name: "regenval"
      value_template: "{{ state_attr('sensor.hwdata','rainmeters')[0].mm}}"
      unit_of_measurement: 'mm'

No it works like a charm.

@bdraco
Copy link
Member

bdraco commented Jan 2, 2021

Looks like the server was being overloaded and closing the connection. It seems like this has been solved by reducing the number of calls to the server.

@bdraco bdraco closed this as completed Jan 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants