Jump to content

Switching from wifi to data needs app restart


Leahkim
Go to solution Solved by darkassassin07,

Recommended Posts

Leahkim

Hello,

Environment:

  • Emby Server 4.7.13.0
  • Emby for Android 3.3.07
  • Android 13
  • Premiere enabled

What is working:

  • Usage internally: wifi and wired connections in the same LAN as the server. Smartphone, PC, TV, even my car with Android Auto through smartphone.
  • Usage externally: data connection through my router/firewall, no problem with my ISP either. Smartphone, car with android auto, other WAN connections.

What is not working:

  • Starting to play playlist inside the LAN and continue after going out, either on smartphone or through Android Auto.

I set up Emby behind an apache proxy to ease certificates, DNS and network flows management through firewall, but I guess it's not the source of the issue.

Internally and externally Emby is reachable through a unique name (eg. emby.myfancydomain.com) and HTTPS/443. As the proxy is doing the routing job, all Emby network config is left by default, proxy falling back on 8096 HTTP default port, this is maybe the problem but I don't know  which parameter to correct, I did several tests without solving.

Testing with local terminal DNS cache is instantly discarded and get the public IP, but I need to restart the app to make it works, so I loose the playlist state on smartphone.

With Android auto it's even worse, I can't restart with the Android auto interface, I need to disconnect the smartphone from the car, restart the app and then reconnect to the car... And of course loosing the playlist and song state.

Fun fact, the reverse action works well, but I don't know if my data connection is still active or if the app switch better when started outside my network and then come back to home.

Thanks in advance,

Leahkim

Link to comment
Share on other sites

lorac

This has been an issue for a long time. A workaround for me is to either switch off Wi-Fi first or download the media you're going to be playing. 

  • Agree 1
Link to comment
Share on other sites

If you're not actively playing media, then our apps can recover automatically from changing networks. When you're actively playing media, this is an area where we need to improve on.

  • Like 1
Link to comment
Share on other sites

  • Solution
darkassassin07
On 8/28/2023 at 4:18 AM, Leahkim said:

Fun fact, the reverse action works well, but I don't know if my data connection is still active or if the app switch better when started outside my network and then come back to home.

For this, you are likely starting with your wan IP, then once on lan emby is still using that wan ip, but the router performs NAT hairpinning to route it back to the lan.

The other way; you're starting with the lan IP, then still trying to use that lan IP once you leave the lan.

Really emby should detect a network change and refresh the connection starting with a fresh dns query.

 

But, in the mean time: Temporarily, you could block lan access at the firewall for everything except the proxy and localhost, then clients would always have to use the wan address.

/edit for clarity: I mean block lan devices from reaching embys ports, but still allow the proxy to reach embys ports. Then LAN devices can only reach the server from the proxy which they will only try via the WAN address shown in the emby server dashboard. If that's a domain that resolves to your WAN address, it'll hairpin back to lan.

 

One caveat though: In the even of an internet outage most clients would likely fail to reach the server as they can't resolve the domain name to the wan address, if you even still have one. You'd still be able to connect on the server machine via localhost, on other devices via the proxy if you manually use it's ip, or just by removing those firewall rules.

 

Just some stuff to think about/play with if you feel like experimenting.

Edited by darkassassin07
Link to comment
Share on other sites

Leahkim

Hello folks,

thanks for your interest and answers.

On 8/28/2023 at 4:03 PM, lorac said:

A workaround for me is to either switch off Wi-Fi first or download the media you're going to be playing. 

Switch off wifi before leaving is the best I found but hard to remember :)

Tested downloading media seems to work, but not fit huge libraries like mine. Thank you for workaround.

On 8/29/2023 at 2:37 AM, Luke said:

If you're not actively playing media, then our apps can recover automatically from changing networks

It's true, I tested it but it takes time, around 2/3 min. In the meanwhile the app is stuck round the round blue line making circles at the center of the screen. Still need to lose playlist state.

On 8/30/2023 at 2:02 AM, darkassassin07 said:

Temporarily, you could block lan access at the firewall for everything except the proxy and localhost

I have an local DNS relay, I will try to change domain resolution to the WAN one and disconnect the cable to simulate an internet connection issue. If it works it can be a full cover workaround, but not available for most people :) Keep you updated soon.

Link to comment
Share on other sites

I use a wireguard vpn to route the traffic and it does not break connection for me switching from wifi (same lan as server) to mobile network 

Link to comment
Share on other sites

Hello all,

On 8/31/2023 at 2:12 PM, x4cbN said:

I use a wireguard vpn to route the traffic

Right, could be a solution too to have a VPN to mount when I leave the LAN, but needs a manual action. If it don't break the connection maybe you have it connected inside the LAN ?

 

On 8/30/2023 at 2:02 AM, darkassassin07 said:

If that's a domain that resolves to your WAN address, it'll hairpin back to lan.

This is the best solution on my situation, thank you very much ! Anyway it's a hard to put in place solution for non-tech people with a simple home NAS running Emby and a NAT.

I did the test, hairpinning is working well and if I disconnect the cable the connection is not broken. Else, if I boot the router with no active the hairpinning never starts, even maybe after a while I could lost the route cache and get it down too, but it's enough for my usage. And if a connection break would last too long, I can still modify my DNS record. It's a rare case so it fits my needs.

Thank you all for help !

  • Like 1
Link to comment
Share on other sites

9 hours ago, Leahkim said:

Right, could be a solution too to have a VPN to mount when I leave the LAN, but needs a manual action. If it don't break the connection maybe you have it connected inside the LAN ?

Yes I am using it inside my wifi / lan to when I start walking around the house and when it switches to mobile or another hotspot it won't break :)

Link to comment
Share on other sites

  • 5 months later...
Gunther123

I am bringing this thread back to life because this issue sits with me too and I love listening to music in my daily life and travel mostly by foot or public transport, so the reliability of the connections is a thing for me and this fix has been on my list of things to do for a long time...

My experience is the client will get caught up when the Emby IP changes, so when I am home and go out or am out and come home, the IP switch is what seems to cause the player to get stuck.

My Emby is running as a docker image with host networking, so it looks like it is locally installed. I did this because I thought it would be neat to have plug-and-play, auto discovery. dlna features but in reality, all the devices I use with Emby are able to run the client, so there is no need for any of this. I don't mind to install a fat client on everything and save login details, so I feel like I would lose no functionality if I bought a domain, setup DDNS and pointed everything to the WAN interface of my modem.

My modem says there has been no outages in the last three years and my IP address changes about every second week, so this is an achievable project.

Are there any considerations I should take? Maybe something I have glossed over?

The hardware I use is Roku for TV, a few Windows computers and mostly Android mobiles. I really cannot think of any DLNA service or devices I might have as all my devices support a full client.

Link to comment
Share on other sites

Leahkim

Hi Gunther123,

The change to public IP resolution even on local network didn't change so much the behaviour of the application, I guess there is routing concerns on my device on something else, the Emby app takes still 2/3 min to back again to play music after losing wifi connection and switch to data.

Most of times I restart the app once outdoor; I think the only real transparent solution is the VPN one, keeping care of routing and sessions through network changes until Emby improve on this point.

To get the VPN working from outside your network you'll need the DDNS.

@Lukeany improve roadmap on this point ?

Link to comment
Share on other sites

Currently the user interface of our apps can recover automatically from network changes. Playback, it just depends. If the server address needs to change from lan to wan or vice versa, currently this does not happen in the middle of playback, but it's something we plan to improve on in future updates. Thanks.

Link to comment
Share on other sites

Tremas
7 hours ago, Luke said:

currently this does not happen in the middle of playback, but it's something we plan to improve on in future updates.

Thanks Luke. This is a needed improvement. It's one of those user experience issues that make the system seem unpolished or buggy.

Link to comment
Share on other sites

Dreakon13

This isn't a feature request in the conventional sense but just want to add a vote to this.  I use Emby for music and radio/podcasts driving into work and literally a minute after I leave my house I hit very, very, very heavy traffic and never get a chance to stop until I'm basically at the office... so as I leave wifi range and the connection gets lost and the music stops, it becomes a difficult game of trying to restart the Emby app, disconnect/reconnect Android Auto, restart the phone, etc to get it working or else I go the whole drive without music (first world problems, but still lol).

I've gotten into the habit of turning wifi off on my phone before I leave the house and it's fine... but for when I forget, it'd be a godsend if it could unscramble itself as I switch networks.

Edited by Dreakon13
  • Agree 2
Link to comment
Share on other sites

Tremas
1 hour ago, Dreakon13 said:

This isn't a feature request in the conventional sense but just want to add a vote to this.  I use Emby for music and radio/podcasts driving into work and literally a minute after I leave my house I hit very, very, very heavy traffic and never get a chance to stop until I'm basically at the office... so as I leave wifi range and the connection gets lost and the music stops, it becomes a difficult game of trying to restart the Emby app, disconnect/reconnect Android Auto, restart the phone, etc to get it working or else I go the whole drive without music (first world problems, but still lol).

I've gotten into the habit of turning wifi off on my phone before I leave the house and it's fine... but for when I forget, it'd be a godsend if it could unscramble itself as I switch networks.

This is my exact situation and the workaround I used until moving most of my music playback to the roon Arc ap. It's an unfortunate pain point for users. 

Link to comment
Share on other sites

  • 1 month later...
Jeffg2024

There are some automation app on Android, e.g., tasker that can switch off wifi and restart emby app when location changes or phone bluetooth connected to car. It needs to open Android permissions though. 

Link to comment
Share on other sites

Karen_G
On 28/8/2023 at 5:18, Leahkim said:

Hola,

Ambiente:

  • Servidor Emby 4.7.13.0
  • Emby para Android 3.3.07
  • androide 13
  • Estreno habilitado

Qué esta trabajando:

  • Uso interno: conexiones wifi y por cable en la misma LAN que el servidor. Smartphone, PC, TV, incluso mi coche con Android Auto a través de smartphone.
  • Uso externo: conexión de datos a través de mi enrutador/firewall, tampoco hay problema con mi ISP. Smartphone, coche con android auto, otras conexiones WAN.

Lo que no funciona:

  • Comenzar a reproducir la lista de reproducción dentro de la LAN y continuar después de salir, ya sea en el teléfono inteligente o mediante Android Auto.

Configuré Emby detrás de un proxy Apache para facilitar la administración de certificados, DNS y flujos de red a través del firewall, pero supongo que no es la fuente del problema.

Se puede acceder a Emby interna y externamente a través de un nombre único (por ejemplo, emby.myfancydomain.com) y HTTPS/443. Mientras el proxy realiza el trabajo de enrutamiento, toda la configuración de la red Emby se deja de forma predeterminada, el proxy recurre al puerto predeterminado HTTP 8096, este es quizás el problema, pero no sé qué parámetro corregir, hice varias pruebas sin resolverlo.

La prueba con la caché DNS del terminal local se descarta instantáneamente y se obtiene la IP pública, pero necesito reiniciar la aplicación para que funcione, por lo que pierdo el estado de la lista de reproducción en el teléfono inteligente.

Con Android auto es aún peor, no puedo reiniciar con la interfaz de Android auto, necesito desconectar el smartphone del coche, reiniciar la aplicación y luego volver a conectarme al coche... Y por supuesto perder la lista de reproducción y el estado de la canción.

Dato curioso, la acción inversa funciona bien, pero no sé si mi conexión de datos todavía está activa o si la aplicación cambia mejor cuando se inicia fuera de mi red y luego regresa a casa.

Gracias de antemano,

leahkim

 

Link to comment
Share on other sites

1 hour ago, Karen_G said:

 

HI, yes, Currently the user interface of our apps can recover automatically from network changes. But during playback, if the server address needs to change from lan to wan or vice versa, currently this does not happen in the middle of playback, but it's something we plan to improve on in future updates. Thanks.

  • Like 1
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...