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

[Support]: Frigate Docker Install HA Supervised 502 Bad Gateway Error #2335

Closed
tjcampanella opened this issue Nov 28, 2021 · 21 comments
Closed

Comments

@tjcampanella
Copy link

Describe the problem you are having

I cannot seem to connect to the web UI for frigate. I have some Lorex cameras and I have been trying to find their RTSP url. I am unsure if I am using the right one I have tried many and none seem to work. When I go to the frigate site it just shows the loading indicator as it is trying to hit the frigate api to no avail. It gets a 502 Bad Gateway error every-time. I appreciate any help.

Version

Latest stable-amd64

Frigate config file

mqtt:
  host: 192.168.1.14
  user: user
  password: password

cameras:
  cam1:
    ffmpeg:
      inputs:
        - path: rtsp://192.168.1.20:554/cam/realmonitor?channel=1&subtype=2
          roles:
            - detect
            - clips
            - record
            - rtmp
    detect:
      width: 1280
      height: 720
      fps: 5

Relevant log output

2021-11-28 14:20:32 ERROR (MainThread) [custom_components.frigate.api] Error fetching information from http://192.168.1.14:5000/api/stats: 502, message='Bad Gateway', url=URL('http://192.168.1.14:5000/api/stats')

FFprobe output from your camera

ffprobe rtsp://@192.168.1.20:554/cam/realmonitor?channel=1&subtype=2
[1] 57220
ffprobe version 4.2.4-1ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[tcp @ 0x5630201ee180] Connection to tcp://192.168.1.20:554?timeout=0 failed: No route to host
rtsp://@192.168.1.20:554/cam/realmonitor?channel=1: No route to host

Frigate stats

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.18.0</center>
</body>
</html>

Operating system

Debian

Install method

Docker Compose

Coral version

M.2

Network connection

Wired

Camera make and model

Lorex E841CA

Any other information that may be helpful

No response

@tjcampanella
Copy link
Author

I got one camera to respond with ffprobe I believe I had the url wrong and the other camera isn't being powered over Poe I think it is too far. Here is the output.

Input #0, rtsp, from 'rtsp://admin:admin@192.168.1.33:554/':
Metadata:
title : Media Server
Duration: N/A, start: 0.140000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuv420p(progressive), 3840x2160, 100 tbr, 90k tbn, 180k tbc

@blakeblackshear
Copy link
Owner

What do the logs for Frigate's docker container show? You posted logs from home assistant, not frigate.

@tjcampanella
Copy link
Author

Oh sorry, here they are.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[2021-11-28 20:57:40] frigate.app INFO : Starting Frigate (0.9.4-26ae608)
Starting migrations
[2021-11-28 20:57:40] peewee_migrate INFO : Starting migrations
There is nothing to migrate
[2021-11-28 20:57:40] peewee_migrate INFO : There is nothing to migrate
timed out
[cmd] python3 exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[2021-11-28 20:58:45] frigate.app INFO : Starting Frigate (0.9.4-26ae608)
Starting migrations
[2021-11-28 20:58:45] peewee_migrate INFO : Starting migrations
There is nothing to migrate
[2021-11-28 20:58:45] peewee_migrate INFO : There is nothing to migrate
timed out
[cmd] python3 exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[2021-11-28 20:59:51] frigate.app INFO : Starting Frigate (0.9.4-26ae608)
Starting migrations
[2021-11-28 20:59:51] peewee_migrate INFO : Starting migrations
There is nothing to migrate
[2021-11-28 20:59:51] peewee_migrate INFO : There is nothing to migrate

@blakeblackshear
Copy link
Owner

It looks like it is failing to connect to your mqtt server (192.168.1.14).

@tjcampanella
Copy link
Author

I'm not sure. How do I check. It looks like it is running fine. The logs on my mqtt server show it is up. I can do a test in ha with it and it works there. Not sure where the issue is.

@tjcampanella
Copy link
Author

MQTT logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] mosquitto.sh: executing...
[16:39:45] INFO: Setting up user mqtt
[16:39:45] INFO: Certificates found: SSL is available
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing...
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[16:39:45] INFO: Starting NGINX for authentication handling...
[16:39:45] INFO: Starting mosquitto MQTT broker...
1638135585: mosquitto version 1.6.12 starting
1638135585: |-- *** auth-plug: startup
[16:39:45] INFO: Successfully send discovery information to Home Assistant.
[16:39:46] INFO: Successfully send service information to the Supervisor.
1638135585: Config loaded from /etc/mosquitto/mosquitto.conf.
1638135585: Loading plugin: /usr/share/mosquitto/auth-plug.so
1638135585: ├── Username/password checking enabled.
1638135585: ├── TLS-PSK checking enabled.
1638135585: └── Extended authentication not enabled.
1638135585: Opening ipv4 listen socket on port 1883.
1638135585: Opening ipv6 listen socket on port 1883.
1638135585: Opening websockets listen socket on port 1884.
1638135585: Opening ipv4 listen socket on port 8883.
1638135585: Opening ipv6 listen socket on port 8883.
1638135585: Opening websockets listen socket on port 8884.
1638135585: Warning: Mosquitto should not be run as root/administrator.
1638135585: mosquitto version 1.6.12 running
1638135585: New connection from 127.0.0.1 on port 1883.
1638135585: Socket error on client , disconnecting.
1638135587: New connection from 172.30.32.1 on port 1883.
1638135587: New client connected from 172.30.32.1 as 4lLwKBWYzO7xv1oOSfljlX (p2, c1, k60, u'mqtt').
1638135625: New connection from 172.30.32.2 on port 1883.
1638135625: Socket error on client , disconnecting.
1638135636: New connection from 172.30.32.1 on port 1883.
1638135636: New client connected from 172.30.32.1 as 47gekrlwRoQXfvHdj5ulFi (p1, c1, k60, u'mqtt').
1638135636: Client 47gekrlwRoQXfvHdj5ulFi disconnected.
1638135670: Socket error on client 4lLwKBWYzO7xv1oOSfljlX, disconnecting.
1638135681: New connection from 172.30.32.1 on port 1883.
1638135681: New client connected from 172.30.32.1 as 3lhej1W7VuPrpDSBItzp4x (p2, c1, k60, u'mqtt').
1638135745: New connection from 172.30.32.2 on port 1883.
1638135745: Socket error on client , disconnecting.
1638135865: New connection from 172.30.32.2 on port 1883.
1638135865: Socket error on client , disconnecting.
1638135985: New connection from 172.30.32.2 on port 1883.
1638135985: Socket error on client , disconnecting.
1638136105: New connection from 172.30.32.2 on port 1883.

@tjcampanella
Copy link
Author

It seems like frigate is trying to connect to the mqtt server, but is failing.

401: Unauthorized1638226898: Socket error on client , disconnecting.
1638226904: New connection from 172.30.32.1 on port 1883.
{"result": "ok", "data": {}}1638226904: New client connected from 172.30.32.1 as 1096ly1TTKDYYfMkdLM4iB (p1, c1, k60, u'mqtt').
1638226904: Client 1096ly1TTKDYYfMkdLM4iB disconnected.
1638226907: New connection from 172.30.32.1 on port 1883.
1638226907: New client connected from 172.30.32.1 as 2PgudLQ6NwS3mlZdgLmkDT (p2, c1, k60, u'mqtt').

I have checked the password it seems to be right.

@tjcampanella
Copy link
Author

It seems like the request is timing out for some reason. That is what the frigate logs say. When I change the ip it just says connection refused so that makes me think I have the right ip which it should just be the ip of my ha instance.

@tjcampanella
Copy link
Author

It's weird to me that i'm not hitting any of the frigate error messages for mqtt. I am just getting "timed out".

@doug62
Copy link

doug62 commented Nov 30, 2021

I get a similar error with no cams, fresh K8 install, no mqtt setup - just pristine (btw - I don't know if this can work that way).
When I go to the main page the client goes into a loop asking for /config but the server is returning 502
Total lockup. Just getting into it, the helm chart doesn't have a log level option and the only concern i have in my logs is that it can't create a db (but it should be able to)...

@blakeblackshear
Copy link
Owner

MQTT is required in current versions.

Normally you would see a reference to the frigate client_id when it connects which is "frigate". I'm not sure why the mqtt error messages sometimes come across without the logging header, but typically that's what I have seen for others in the past.

@tjcampanella
Copy link
Author

I have tested using a command line MQTT tool to connect to my MQTT server running on home assistant and it was able to connect and send a message. So I know I am using the right IP, I am unsure why frigate cannot connect to it.
Frigate gives me this time out error every time.

Screen Shot 2021-12-14 at 9 45 33 PM

@tjcampanella
Copy link
Author

@blakeblackshear Do you have any tips for debugging this? I have been trying everything I can think of with no luck. I am using Lorex Cameras. I don't know if it is because of it not connecting to mqtt or if it can't connect to the camera.

@blakeblackshear
Copy link
Owner

I have never been able to reproduce this type of error message. Are you using the Hass Addon for MQTT? Is Frigate running on a separate machine?

@tjcampanella
Copy link
Author

I never got it working in the docker container. However, I switched to using the HA addon with this url for mqtt core-mosquitto.local.hass.io and it worked. For some reason the docker standalone container could not resolve the ip. When adding it through home assistant as an addon it could, but only using that url.

@tjcampanella
Copy link
Author

Now I am just trying to figure out how to get my cameras other streams. I want to have a regular 20fps or something stream on my dashboards and use the 5fps for frigate detection. I am using Lorex cameras most of the urls I have tried have failed. Only ones that work are rtsp://user:pass@ip:554/ and tsp://user:pass@ip:554/live. Both of those give the same stream too.

@secabeen
Copy link

I have never been able to reproduce this type of error message. Are you using the Hass Addon for MQTT? Is Frigate running on a separate machine?

I was able to reproduce this and fix it. In my case, using docker-compose (instead of docker run) caused a new network interface and docker network to be created for this container. That network was not in my list of allowed networks, and with a default-deny firewall rule, it was making it impossible for Frigate to reach my MQTT server. Once I figured out the state of the network, and opened my firewall to the new network for docker-compose, it worked.

As a suggestion, it might be useful to add some connection data to the error message, going from "timed out" to "timed out connecting to MQTT server: 1.2.3.4:1883". That would give a hint to people who run into this that it might be a firewall issue.

@blakeblackshear
Copy link
Owner

That's the thing. This error message seems to come from somewhere I don't control. I don't have any way to modify the message because nothing in my code produces it.

@enkama
Copy link

enkama commented Dec 27, 2021

I have never been able to reproduce this type of error message. Are you using the Hass Addon for MQTT? Is Frigate running on a separate machine?

I was able to reproduce this and fix it. In my case, using docker-compose (instead of docker run) caused a new network interface and docker network to be created for this container. That network was not in my list of allowed networks, and with a default-deny firewall rule, it was making it impossible for Frigate to reach my MQTT server. Once I figured out the state of the network, and opened my firewall to the new network for docker-compose, it worked.

As a suggestion, it might be useful to add some connection data to the error message, going from "timed out" to "timed out connecting to MQTT server: 1.2.3.4:1883". That would give a hint to people who run into this that it might be a firewall issue.

What exactly did you do to fix it? I am also getting millions of 502 Bad Gateaway error in the browser console and its not loading. Actually its getting spammed that much that my browser starts lagging. It shows 502 Bad gateaway with method get and file "config" (http://...:***/api/config)

@secabeen
Copy link

What exactly did you do to fix it? I am also getting millions of 502 Bad Gateaway error in the browser console and its not loading. Actually its getting spammed that much that my browser starts lagging. It shows 502 Bad gateaway with method get and file "config" (http://...:***/api/config)

I'm not getting the bad gateway errors, just the "timed out" error in my logs. In my case, the problem was that the firewall on my MQTT server was not configured to allow traffic from the network/interface created by docker-compose for my containers. (I had previously used docker run to start my containers, which used the default docker network. When I switched to docker-compose that created a new network that I needed to add to my firewall allow list.)

@stale
Copy link

stale bot commented Jan 26, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 26, 2022
@stale stale bot closed this as completed Jan 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants