[Freeswitch-users] Serving sofia.conf via lua (updated, partly resolved)

Antony Stone Antony.Stone at freeswitch.open.source.it
Tue Nov 30 13:17:47 UTC 2021


On Tuesday 30 November 2021 at 11:20:02, Antony Stone wrote:

> I am trying to get Freeswitch to get its sofia configuation from lua
> instead of static XML files.

I've worked out what the problem was, even before my question/s appear to have 
reached the list!?

It turns out that I needed to move:

    <load module="mod_lua"/>

much higher up in /etc/freeswitch/autoload_configs/modules.conf.xml so that it 
got loaded before:

    <load module="mod_sofia"/>

After that, my lua script's configuration does get used to configure sofia :)

(This seems like either missing documentation, or even an inappropriate 
default setting to me - after all, in what circumstance would it be better to 
load lua after nearly everything else, given that it can be used to actually 
configure everything else and is then needed first?)


Anyway, I now have another problem.

If I take my (static, nothing fancy yet) and monolithic sofia configuration file 
and put it into /etc/freeswitch/autoload_configs/sofia.conf.xml (and disable 
lua) then it does what I expect and all works.

If I take the same file and put it into my lua script (correctly enclosed 
within the extra <document> and <section> tags), then it does get loaded, but 
it produces errors relating to some of the variables pre-defined in vars.xml.

So, for example, one of my SIP profiles contains:

    <param name="rtp-ip" value="$${local_ip_v4}"/>
    <param name="sip-ip" value="$${local_ip_v4}"/>

This produces (when sofia gets loaded) the error messages:

--------
tport.c:1844 tport_server_addrinfo() tport_server_addrinfo(0x56318f75ee20): 
su_getaddrinfo($${local_ip_v4}, 5080) for *: Name or service not known

nta.c:2276 nta_agent_add_tport() nta: 
bind($${local_ip_v4}:5080;transport=*;maddr=$${local_ip_v4}): No such file or 
directory

nua_stack.c:195 nua_stack_init() nua: initializing SIP stack failed
--------

Inside the console fs_cli I can do:

	eval $${local_ip_v4}

and it gives me the correct answer.


If I replace $${local_ip_v4} in the xml configuration delivered by lua with the 
numeric IP address, then sofia loads and works as it did with the plain XML file 
in /etc/freeswitch/autoload_configs/sofia.conf.xml

However, I see that some other variables, also defined in vars.xml, are being 
correctly interpreted and used from the XML provided by lua, so this isn't a 
consistent "you can't reference variables" problem.


Does anyone have a clue what I need to do to fix this?


Thanks,


Antony.

-- 
I bought a book about anti-gravity.  The reviews say you can't put it down.

                                                   Please reply to the list;
                                                         please *don't* CC me.



More information about the FreeSWITCH-users mailing list