question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Websocket connections are being terminated over subdomain (reverse proxy)

See original GitHub issue

Describe the bug On the latest release 9 docker image blakeblackshear/frigate:0.9.0-2181379-amd64, the live stream view is not working when viewed over a reverse proxy. More specifically,

https://frigate.mydomain.com image

The debug view works fine. Also, the same view stream view works fine when directly going via IP.

I’ve had this set up for over a year and it appears the latest beta v9 and this latest frigate:0.9.0-2181379-amd64 build starting producing this error.

I believe the issue is in the WS layer. In the screenshot above the JSmpegplayer websocket appears to keep dying and retrying. Since the jsmpeg player is a recent addition, I think this is probably where the problem got introduced.

image

Version of frigate frigate:0.9.0-2181379-amd64

Frigate container logs

Starting migrations
[2021-08-15 20:10:22] peewee_migrate INFO : Starting migrations
There is nothing to migrate
[2021-08-15 20:10:22] peewee_migrate INFO : There is nothing to migrate
[2021-08-15 20:10:22] frigate.mqtt INFO : MQTT connected
[2021-08-15 20:10:22] detector.coral0 INFO : Starting detection process: 234
[2021-08-15 20:10:22] detector.coral1 INFO : Starting detection process: 236
[2021-08-15 20:10:22] frigate.edgetpu INFO : Attempting to load TPU as pci:1
[2021-08-15 20:10:22] frigate.edgetpu INFO : TPU found
[2021-08-15 20:10:22] frigate.edgetpu INFO : Attempting to load TPU as pci:0
[2021-08-15 20:10:22] frigate.edgetpu INFO : TPU found
[2021-08-15 20:10:22] frigate.app INFO : Output process started: 240
[2021-08-15 20:10:22] ws4py INFO : Using epoll
[2021-08-15 20:10:22] frigate.app INFO : Camera processor started for kitchen: 248
[2021-08-15 20:10:22] frigate.app INFO : Camera processor started for frontdoor: 264
[2021-08-15 20:10:22] frigate.app INFO : Camera processor started for driveway: 275
[2021-08-15 20:10:22] frigate.app INFO : Camera processor started for shed: 277
[2021-08-15 20:10:22] frigate.app INFO : Camera processor started for livingroom: 279
[2021-08-15 20:10:22] frigate.app INFO : Camera processor started for culdesac: 280
[2021-08-15 20:10:22] frigate.app INFO : Camera processor started for garage: 282
[2021-08-15 20:10:22] frigate.app INFO : Capture process started for kitchen: 283
[2021-08-15 20:10:22] frigate.app INFO : Capture process started for frontdoor: 287
[2021-08-15 20:10:22] frigate.app INFO : Capture process started for driveway: 292
[2021-08-15 20:10:22] frigate.app INFO : Capture process started for shed: 297
[2021-08-15 20:10:22] frigate.app INFO : Capture process started for livingroom: 303
[2021-08-15 20:10:22] frigate.app INFO : Capture process started for culdesac: 308
[2021-08-15 20:10:22] frigate.app INFO : Capture process started for garage: 314
[2021-08-15 20:10:22] ws4py INFO : Using epoll
[2021-08-15 20:10:26] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41764]
[2021-08-15 20:10:26] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41764]
[2021-08-15 20:10:27] frigate.record INFO : bad file: culdesac-20210815200950.mp4
[2021-08-15 20:10:27] frigate.record INFO : bad file: livingroom-20210815200948.mp4
[2021-08-15 20:10:27] frigate.record INFO : bad file: driveway-20210815200948.mp4
[2021-08-15 20:10:27] frigate.record INFO : bad file: garage-20210815200948.mp4
[2021-08-15 20:10:27] frigate.record INFO : bad file: shed-20210815200948.mp4
[2021-08-15 20:10:27] frigate.record INFO : bad file: kitchen-20210815200947.mp4
[2021-08-15 20:10:27] frigate.record INFO : bad file: frontdoor-20210815200947.mp4
[2021-08-15 20:11:10] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41764]
[2021-08-15 20:11:10] ws4py INFO : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:39486]
[2021-08-15 20:11:10] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41766]
[2021-08-15 20:11:20] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41768]
[2021-08-15 20:11:20] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41768]
[2021-08-15 20:11:25] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41770]
[2021-08-15 20:11:26] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41770]
[2021-08-15 20:11:31] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41774]
[2021-08-15 20:11:31] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41774]
[2021-08-15 20:11:31] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41774]
[2021-08-15 20:11:31] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41774]
[2021-08-15 20:12:19] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41776]
[2021-08-15 20:12:19] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41776]
[2021-08-15 20:12:24] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41778]
[2021-08-15 20:12:25] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41778]
[2021-08-15 20:12:30] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41780]
[2021-08-15 20:12:30] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41780]
[2021-08-15 20:12:35] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41782]
[2021-08-15 20:12:35] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41782]
[2021-08-15 20:12:41] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41784]
[2021-08-15 20:12:41] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41784]
[2021-08-15 20:12:41] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41784]
[2021-08-15 20:12:41] ws4py INFO : Terminating websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41784]
[2021-08-15 20:12:47] ws4py INFO : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:39488]
[2021-08-15 20:12:47] ws4py INFO : Managing websocket [Local => 127.0.0.1:5002 | Remote => 127.0.0.1:39488]
[2021-08-15 20:12:47] ws4py INFO : Managing websocket [Local => 127.0.0.1:8082 | Remote => 127.0.0.1:41786]

Add any other context about the problem here.

Reverse Proxy Config

location /authelia {
internal;
set $upstream_authelia http://X..X.X:9091/api/verify;
proxy_pass_request_body off;
proxy_pass $upstream_authelia;    
proxy_set_header Content-Length "";

# Timeout if the real server is dead
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
client_body_buffer_size 128k;
proxy_set_header Host $host;
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr; 
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Uri $request_uri;
proxy_set_header X-Forwarded-Ssl on;
proxy_redirect  http://  $scheme://;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_cache_bypass $cookie_session;
proxy_no_cache $cookie_session;
proxy_buffers 4 32k;

send_timeout 5m;
proxy_read_timeout 240;
proxy_send_timeout 240;
proxy_connect_timeout 240;
}

location / {
set $upstream_CONTAINERNAME $forward_scheme://$server:$port;
proxy_pass $upstream_CONTAINERNAME;

auth_request /authelia;
auth_request_set $target_url https://$http_host$request_uri;
auth_request_set $user $upstream_http_remote_user;
auth_request_set $groups $upstream_http_remote_groups;
proxy_set_header Remote-User $user;
proxy_set_header Remote-Groups $groups;
error_page 401 =302 https://auth.vanillax.me/?rd=$target_url;

client_body_buffer_size 128k;

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;

send_timeout 5m;
proxy_read_timeout 360;
proxy_send_timeout 360;
proxy_connect_timeout 360;

proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Uri $request_uri;
proxy_set_header X-Forwarded-Ssl on;
proxy_redirect  http://  $scheme://;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_cache_bypass $cookie_session;
proxy_no_cache $cookie_session;
proxy_buffers 64 256k;

set_real_ip_from 192.168.1.0/16;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
blakeblackshearcommented, Aug 16, 2021

I’m not having any issues with my traefik proxy. I’m not sure what the difference is.

0reactions
stale[bot]commented, Sep 30, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nginx reverse proxying websockets - Stack Overflow
The simplest solution would be to setup virtual hosts in nginx for multiple subdomains and run each service on a separate one.
Read more >
Server-Sent Events: the alternative to WebSockets you should ...
First, we need to create a new WebSocket object passing the URL of the server. Here wss indicates that the connection is to...
Read more >
Using NGINX as a WebSocket Proxy
Learn how to use NGINX as a reverse proxy and load balancer for WebSocket applications.
Read more >
Reverse Proxy Configuration | YouTrack Server Documentation
Secure the Connections to Your YouTrack Server. Reverse Proxy ... You can set up YouTrack to work behind a reverse proxy server.
Read more >
How do I proxy requests to a subdomain to a different port on ...
1 Answer 1 ... When an http-request is received by apache it has to decide which configuration applies. When a host header matches...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found