esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

ESP32Cam causes #332

Closed spattinson closed 5 years ago

spattinson commented 5 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

Home assistant (0.93.1) on Hassbian without docker. Exposed to the internet with a letsencrypt cert using my own domain name

ESP (ESP32/ESP8266, Board/Sonoff):

ESP32 AIthinker Affected component:

esp32cam

Description of problem: Esp32cam invalid login attempt Including esp32cam in lovelace frontend causes Login attempt failed: login attempt or request with invalid authentication from Browser is Chrome on Android How to reproduce: Open Frontend, switch to another app or leave phone to go to sleep for a while leaving home assistant idle in background. After some time open home assistant again on phone. Immediately the above error is triggered. This causes ip_ban to be triggered.

Problem-relevant YAML-configuration entries: Sections from configuration.yaml:

  auth_providers:
    - type: homeassistant

http:
  base_url: xxx.co.uk:8443
  server_port: 8443
  ssl_certificate: /etc/letsencrypt/live/xxx.co.uk/fullchain.pem
  ssl_key: /etc/letsencrypt/live/xxx.co.uk/privkey.pem
  ip_ban_enabled: true
  login_attempts_threshold: 50

esphome yaml:

  name: cam1
  platform: ESP32
  board: esp-wrover-kit

wifi:
  ssid: 'xxxx'
  password: 'xxxx'

api:

logger:

ota:
  password: xxxxx

web_server:
  port: 80

switch:
  - platform: restart
    name: "Cam1 Restart"

output:
  platform: gpio
  id: flashlight1
  pin: GPIO4

light:
  - platform: binary
    name: Cam1 Flashlight
    output: flashlight1

esp32_camera:
  name: Cam1
  external_clock:
    pin: GPIO0
    frequency: 20MHz
  i2c_pins:
    sda: GPIO26
    scl: GPIO27
  data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34, GPIO35]
  vsync_pin: GPIO25
  href_pin: GPIO23
  pixel_clock_pin: GPIO22
  power_down_pin: GPIO32
  power_down_pin: GPIO32
  resolution: VGA

Traceback (if applicable):

I connected to my Chrome instance using a desktop debugging session to see the error from the browser perspective:

:8443/api/camera_proxy/camera.cam1?token=54ef9dabb6e019cdbecdcc3ae1c15348fce1c5162db37dcdd043dc6781624bd1:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)
core.284296d9.js:1 WebSocket connection to 'wss://ferrisangling.co.uk:8443/api/websocket' failed: Error in connection establishment: net::ERR_INTERNET_DISCONNECTED
e @ core.284296d9.js:1
:8443/api/camera_proxy/camera.cam1?token=f86180354b077da30c8499fbd39c8e6447f7e7d7a0c9757b04d878445ad1d605:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)
camera.cam1:1 Failed to load resource: the server responded with a status of 401 (Unauthorized)

Additional information and things you've tried: I made tried turning off "data saver" in Chrome it made no difference I set logger to debug level for http auth auth_providers it yeilded no further information other than the original error. Removed the esp32cam component from my frontend and the errors stopped happening. The error occurrs whether you are on the local network or remove (wifi vs 4g)

My esp32cam was last flashed on May 3. I am concerned that my IP will get banned so have set my login retries to 50. It would be preferable from a security perspective to set that lower and not see and read the persistant notifications in the frontend unless there is an actual unauthorised person trying to break in. I am away until Mon 27 May, I can do further testing

OttoWinter commented 5 years ago

Well that must be a bug in home assistant then. Esphome only delivers the JPG stream - anything that has to do with the HA frontend definitely is a bug in HA then.

Also note ESPHome does not support the HA "stream" feature - that might be what you're seeing here.

Please open an issue in https://github.com/home-assistant/home-assistant