Jump to content

[SOLVED] Emby for Kodi - Does websockets SNI correctly?


Steve86

Recommended Posts

Steve86

Hey guys,
 
first of all: Emby for Kodi is the reason why i came to emby. Great app, much appreciated. @@Angelblue05 @@sualfred
 
I'm still testing a lot of stuff but i found some errors in my kodi.log. Every five seconds it gives me a never ending loop of these:

NOTICE: EMBY.entrypoint.service -> [ onNotification/plugin.video.emby/WebSocketRestarting ]
NOTICE: Emby.emby.core.ws_client -> ERROR:: Handshake Status 503

Debug logging within emby for kodi will add these two lines:

NOTICE: EMBY.helper.utils -> DEBUG:: ---[ event: plugin.video.emby/WebSocketRestarting ] "[{}]"
NOTICE: EMBY.entrypoint.service -> DEBUG:: [ plugin.video.emby: WebSocketRestarting ] {}

The http error code 503 comes from my haproxy, which does SNI and SSL-offloading (e.g. by emby.domain.com) on port 443 and will return a 503, if you use none or a non existent hostname in your request. Making emby server and emby.domain.com my the default (fallback), the websocket will work with haproxy. For obvious reasons i don't want to use my emby server as 'default backend' on any request on port 443.
 
Haproxy logs show, that the request is:

"GET /embywebsocket?api_key=<removed>&device_id=<removed> HTTP/1.1"

(See update at the end) Unfortunately i could not figure a way to make haproxy or emby for kodi show me the whole request with the hostname, so one can only guess, that is might not be the hostname but maybe only the ip address?
 
While searching about this, i only found this locked topic, from which i didn't get any helping hints. I understand there was a fix in the websockets request in 2017 which added a slash before the 'embywebsocket':
https://emby.media/community/index.php?/topic/50062-web-sockets-and-reverse-proxy/
 
Since i can see the get request with the leading slash, i figure this can't be the reason for the 503.
 
Of cause i'd like to rule out a configuration error on the haproxy side. Since streaming and database updates seem to work as long with the workaround using emby server as default backend for SNI, in my opinion this has to be a websocket request specific problem.
 
So my first question would be:
 
Does anybody have this working with reverse proxy and SNI (without emby as default backend)?
 
On the other hand i'm not sure what the websocket is used for. I figured it might be the 'send message' feature from server to client or the 'inform about new content' over 'server is restarting' and so on.
 
Which features depend on a websocket to the emby server? Is it 'required'?
 
I'd also like to look further into this, but i can't seem to find the full websocket request in any log.
 
Is there a way to see the whole request somewhere in emby for kodi?
 
I'm running:
- emby for kodi 4.1.19
- Libreelec 9.2.2 with Kodi 18.6
- Emby server 4.4.2.0
 
Thanks for your help or hints in advance.
Steve
 
UPDATE:
 
I figured how to make haproxy capture the sent host headers from the http request and log them. The problems seems to be that an additonal colon from the appending port remains inside the host header (e.g. emby.domain.com: ). This seems to be the reason why haproxy can't find the hostname. Is this a bug inside Kodi for Emby? I use 'manual server' with 'https://emby.domain.com:443'.This still only happens with the websockets request. Can someone tell, how this request does handle the host header differently from the other requests?
 
SOLUTION:
 
Emby for Kodi does SNI correctly. It turned out i had my haproxy configuration wrong. It was redirecting to emby server based on the host header within the http request, but it should have redirected by the SNI within the tcp request. I set it to sni and now it works perfect. Thanks for pointing me back to the haproxy logs and sorry for wasting your time @@Luke.

Edited by Steve86
Link to comment
Share on other sites

 

 

that is might not be the hostname but maybe only the ip address?

 

Hi, you should be able to see the requested url from your reverse proxy logging, no?

  • Like 1
Link to comment
Share on other sites

Steve86

Hi, you should be able to see the requested url from your reverse proxy logging, no?

Hey Luke, as stated in my update, i did get haproxy to log it and the host header has a colon an the end, which does not belong there. I'll update the rest of my post to make this clear. I'm still wondering why there this colon only in the websockets request...any guess?

 

The logged host is emby.domain.com: which is no valid http host, right?

Edited by Steve86
Link to comment
Share on other sites

If truly that's what it's suggesting than yes it doesn't look right, but we've had this in place for a long time so I would think that would have been caught by now.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...