freeswitch/mod_janus

Hot reload janus.conf.xml

Closed this issue · 7 comments

Hi there, just gave Freeswitch and this plugin a first try, and it both gives a great experience for a developer. Thank you!

Is your feature request related to a problem? Please describe.
We deploy janus horizontally, depending on the load our users generate. At the moment I start Freeswitch, I do not know yet, which servers will be relevant or even exist for using mod_janus. Use case is obvious: joining a video conference via PSTN.

Describe the solution you'd like
It would be awesome if I could just reload the janus.conf.xml by api or if it would load it periodically the file. Or if I could add and remove servers through the api. I'd just need some kind of hot reload so I can add and remove servers dynamically.

Describe alternatives you've considered
I tried "reload mod_janus" but since I simulated a running call, It was not possible to unload and load the module because it is locked (and I obviously don't want to stop any running calls). I also looked into the code but did not find any hints how a mechanism could look like if there is one.

Additional context
Did I miss something? Is there any given mechanism in Freeswitch or in the module how I could accomplish this task? Or is this a use case nonsense from your point-of-view?

Thank you!

Kinds regards,
Max

Richard, I am planning to implement this feature. My C skills are somewhat limited, but I will get this running somehow.

Would you merge a pull request?

I probably will expand the configuration like this:

<configuration name="janus.conf" description="Janus Endpoint">
  <settings>
    <param name="debug" value="false"/>
    <param name="dynamic-server" value="https://example.org/rest/get-janus-server" interval="10"/>
  </settings>
</configuration>

The rest api will return a JSON which corresponds to your xml 'server' tag and the module will update its' servers every n seconds according to the interval.

Are you ok with that?

Hi @maxboehm,

First of all apologies for not responding to this issue sooner - I have very little time for this project at the moment and I did not receive any notification of your issue.

I'm not sure that your solution is the best approach. The module was not written to support large number of Janus servers and I expect you could run into all sorts of race conditions (particularly when removing servers).

Have you considered placing a load-balancer in front of the Janus servers and just configure a single Janus server in FreeSWITCH?

I apologise if my reply is too late to be of use!

Hello @richardscreene,

no worries! My answer also took some days, eh, weeks :-)

Yeah, we ran into some race conditions and we the ones we found. We'll submit a PR as soon as our time is less limited.

Should be okay, right?

Yes, it's MPL 1.1 as dictated by freeswitch.

Let me know when you've published and I put a link to it in the readme.

Be careful of memory leaks!!! (I seem to remember it was a right pain getting rid of them when terminating a server)

Good luck!