elixir-webrtc / apps

Example apps built on top of Elixir WebRTC
Apache License 2.0
41 stars 4 forks source link

[nexus] Runtime configuration of ICE candidates #63

Open Megzo opened 4 days ago

Megzo commented 4 days ago

Hi Everyone,

I'm running some experiments using the Nexus app in a Kubernetes environment. Since I'm using STUNner (basically a Kubernetes native TURN server) I needed to add my own TURN server as an ICE candidate. Currently I think there is no way to change the ICE config during runtime, so I needed to fork the project then build my own Docker image using a specific TURN server. This worked fine, but it would be nice to have a way to configure the ICE candidate in runtime.

The are two files containing the ICE config (for client and server):

Usually .js files can be overwritten during runtime in Kubernetes using ConfigMaps, but this was not as obvious to do so, since the file itself is quite large, and there are also minimized and gzipped versions in the container. To that end, it would be nice if the ICE config would be in a separate .js file.

On the server side, I have zero experience with Elixir, so I have no idea how to use an ENV variable for this purpose (especially that TURN config requires more parameters, e.g. username and password).

If you also value in this feature, can you help me add this to Nexus (and maybe to the other projects as well)?

sgfn commented 3 days ago

Hi @Megzo, We'll be more than happy to make ICE servers configurable at runtime. Server-side (peer.ex), this should be pretty easy and we can take care of it, however, I'm not sure I understand how exactly you mean to configure it in the client-side code.

Extracting the ICE config to a separate .js file can be done ofc, but the minified and gzipped versions of the frontend assets are generated while building the Docker image. In the Dockerfile, this is done using mix assets.deploy which is an alias for these three tasks:

I'm not really that familiar with frontend development as a whole (and, for that matter, Kubernetes as well), so it's hard for me to say whether it's possible to somehow overwrite assets generated in this way at runtime. If you're determined to bring this feature without having to build your own Docker image, you can look into this topic and see if anyone has tried (and succeeded) to do something like this with Phoenix before.

Would you be willing to look for a potential solution to this issue?

Megzo commented 2 days ago

Hi @sgfn

Thanks for the quick replay. Sure, I'll look into how to organiz the .js files to that end. I'll get back to you, when I have the idea.