Access gateway/profile params/variables in Freeswitch - freeswitch

To get variables from a user we call user_data(user var variable_name).
<include>
<user id="1000">
<variables>
<variable name="custom_variable" value="test"/>
</variables>
</user>
</include>
We call in a way like that:
<action application="set" data="variable_name=${user_data(${caller_id_number}#${domain_name} var custom_variable)}"/>
But how to do the same with a gateway?
<include>
<gateway name="custom_gateway">
<param name="custom_param" value="test"/>
</gateway>
</include>

I think it is not possible.
FS application set is 'Set a channel variable for the channel calling the application' while gateway data is somewhere in the sofia module. However, there is a way to list gateway data from console. Have a look at sofia_gateway_data_function in the source code, hope it sheds some light on what you need to do. Good luck!

Related

Azure Cloud Service (classic) web role with load balancer probe doesn't seem to work for HTTPS

I am trying to change an old classic cloud service to use an HTTP health probe instead of the default process-based check. We've had some issues where instances stopped working but it thought they were still usable because they were running, but couldn't respond to requests.
Our site is HTTPS only, we don't even have an HTTP endpoint defined. Or didn't. The load balancer doesn't support HTTPS, so I had to add an HTTP endpoint and configure that to be used instead. That's gross but it seems to work. However, the HTTPS site doesn't seem to be covered by the health checks for the HTTP endpoint.
If I query my health probe path via HTTP, I can see that it's returning a 503, and if all instances return a 503 I can see that endpoint fail to load until I make one return 200 again. Once I make one return a 200 again, it works. My requests get routed to the appropriate node, if possible.
However, the HTTPS requests always seem to go to the same instance, regardless of the probes. Flipping that instance from 200 to 503 doesn't cause those requests to go to the other instance, like it does with HTTP. It isn't balanced at all.
It's really hard to find useful documentation or examples on how this should be set up or if it can work at all. Below is my csdef file. Is it possible to get this working (either an HTTPS check or the HTTP check affecting the HTTPS endpoint)?
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="..." xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<LoadBalancerProbes>
<LoadBalancerProbe name="health" protocol="http" port="80" path="health" intervalInSeconds="5" timeoutInSeconds="11"></LoadBalancerProbe>
</LoadBalancerProbes>
<WebRole name="..." vmsize="Standard_D2_v3">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
<Binding name="LoadBalancerEndpointBinding" endpointName="LoadBalancerEndpoint" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="https" port="443" certificate="..." />
<InputEndpoint name="LoadBalancerEndpoint" protocol="http" port="80" loadBalancerProbe="health" />
</Endpoints>
<ConfigurationSettings>
<!-- ... -->
</ConfigurationSettings>
<Certificates>
<!-- ... -->
</Certificates>
</WebRole>
</ServiceDefinition>
The answer in my case was to add the loadBalancerProbe attribute to both endpoint elements. I also had to make sure that however I was testing the service made new connections for every request or they would always go to the same instance (e.g. HttpClient pools connections internally per instance). This is essentially the new working configuration file:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="..." xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<LoadBalancerProbes>
<LoadBalancerProbe name="health" protocol="http" port="80" path="health" intervalInSeconds="5" timeoutInSeconds="11"></LoadBalancerProbe>
</LoadBalancerProbes>
<WebRole name="..." vmsize="Standard_D2_v3">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
<Binding name="LoadBalancerEndpointBinding" endpointName="LoadBalancerEndpoint" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="https" port="443" certificate="..." loadBalancerProbe="health" />
<InputEndpoint name="LoadBalancerEndpoint" protocol="http" port="80" loadBalancerProbe="health" />
</Endpoints>
<ConfigurationSettings>
<!-- ... -->
</ConfigurationSettings>
<Certificates>
<!-- ... -->
</Certificates>
</WebRole>
</ServiceDefinition>

Play an ivr based on hangup cause

Is there anyway to play an ivr based on Hangupcause ?
Right now i have tried below dialplan but seems like its not working.
So please suggest if there is any other way i can achieve it.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="dialplan" description="Custom_dialplan">
<context name="default">
<extension name="123456">
<condition field="destination_number" expression="123456">
<action application="set" data="effective_destination_number=123456"/>
<action application="set" data="transfer_on_fail=RECOVERY_ON_TIMER_EXPIRE auto_cause xml error"/>
<action application="bridge" data="sofia/gateway/Dummy_Gateway/123456"/>
<action application="log" data="AFTER BRIDGE"/>
</condition>
</extension>
</context>
<context name=error">
<action application="log" data="AFTER BRIDGE2"/>
<extension name="RECOVERY_ON_TIMER_EXPIRE" continue="true">
<action application="log" data="AFTER BRIDGE3"/>
<condition field="${originate_disposition}" expression="RECOVERY_ON_TIMER_EXPIRE" continue="false" break="on-true">
<action application="log" data="AFTER BRIDGE4"/>
<action application="playback" data="/usr/local/freeswitch/sounds/en/us/callie/notinservice.wav"/>
</condition>
</extension>
</context>
</section>
</document>
Definitely, you have done few mistakes in your dialplan while it is significant:
Before use transfer_on_fail you should set up another obligatory options follows:
<action application="set" data="continue_on_fail=true"/>
<action application="set" data="failure_causes=RECOVERY_ON_TIMER_EXPIRE"/>
To remove that logging option BRIDGE due to it's useless and it will never be handled.
I would like to draw your attention the dialplan has strict structure, so you can't insert options/actions wherever you want. First of all, you should remove all logging from the context ERROR
-- The sequence is going to be: context -> extension --> condition --> action (s). Thus you have setup the condition follows with the action playing announcement.
--!-- You have taken call handling in your hands, so please manage the process. After your platform had played to leg A you have to instruct FreeSWITCH terminating the call (it must follow "playback"):
<action application="hangup" data="NORMAL_CLEARING"/>
However, I assume your dialplan won't work ever because RECOVERY_ON_TIMER_EXPIRE is the status of Freeswitch State Machine which appear when SIP 408. You should use Q.850 hangup cause in dialplan instead, so try replacing it with NO_USER_RESPONSE.
You may find Q.850 hangup cause table here

MSDeploy setParameter not working

We are trying to integrate a 'build once, deploy anywhere' model in our build-deploy system.
MSDeploy works wonders for this, cutting down build time dramatically with CRC checksum comparisons and (for the most part) it works just as well when using parameterisation to change applications web.configs depending on the environment we deploy to.
I have the majority of these parameters nailed down, but a few elements and attributes never seem to change, no matter how many different ways I call them in the parameters.xml file. I have outlined three examples of this, here is the web.config file I am trying to change:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="DbConnectionString" connectionString="Data Source=null;Initial Catalog=null;Trusted_Connection=no;User ID=user1;Password=pass*9;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="On" defaultRedirect="/Library/Error/PageNotFound.aspx">
</customErrors>
</system.web>
<applicationSettings>
<settings>
<setting name="service_Address" serializeAs="String">
<value></value>
</setting>
<settings>
</applicationSettings>
</configuration>
Here is the parameters.xml file:
<parameter name="DbConnectionString" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[#name='DbConnectionString']/#connectionString" />
</parameter>
<parameter name="customErrorsMode" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="configuration/system.web/customErrors/#mode" />
</parameter>
<parameter name="service_Address" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/aim.Web.Properties.Settings/setting[#name='service_Address']/value" />
</parameter>
And here is the corresponding setParameters.xml file:
<setParameter name="DbConnectionString" value="Data Source=dbserver;Initial Catalog=DB1;Trusted_Connection=no;User ID=user1;Password=pass*9;"/>
<setParameter name="customErrorsMode" value="Off"/>
<setParameter name="service_Address" value="https://myservice.asmx"/>
I have tested each XPath expression and the results are the exact same as any of the other working parameters, but the above never seem to change.
Does anyone see anything obvious I'm missing here?
service_Address
I found the answer to this problem here:
Replace web.config elements with MSDeploy
I was missing 'text()' at the end of the XPath expression, the correct XPath is:
/configuration/applicationSettings/aim.Web.Properties.Settings/setting[#name='ai‌​m_Web_AddressService_Address']/value/text()
customErrorsMode
For the customErrorsMode problem, I was missing a '/' at the start of my XPath expression. The correct expression is:
/configuration/system.web/customErrors/#mode
connectionStrings
This one really got to me, it was the last one I figured out. After doing a bit of digging I found out that MSDeploy automatically parameterizes certain elements, connection string being one of them, more info here:
Configuring Parameters for Web Package Deployment
My parameter declaration for the connection string in question should have been:
<parameter name="DbConnectionString-Web.config Connection String" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[#name='DbConnectionString']" />
</parameter>
My setParameter definition should have looked like this:
<setParameter name="DbConnectionString-Web.config Connection String" value="Data Source=dbserver;Initial Catalog=DB1;Trusted_Connection=no;User ID=user1;Password=pass*9;" />

WSO2 ESB URL Rewrite has no effect?

I'm trying to modify an URL with a URLrewrite mediator but it seems to has no effect.
I want to replace the word "user1" to "customer1", and then send the request to an endpoint
In my proxy i recieve this URL:
"/services/myproxy/user1"
And i have to rewrite it to:
"/services/myproxy/customer1" (and then to endpont: "http://endpoint.com/customer1").
The URLRewrite mediator is:
<rewrite xmlns="http://ws.apache.org/ns/synapse">
<rewriterule>
<action value="customer1" regex="user1" type="replace" fragment="path"/>
</rewriterule>
</rewrite>
but at the end the proxy sends the URL request with "user1" instead of "customer1"!!
whats wrong in my config?? I don't see any errors in my log!!
thanks!!!
Following syntax is working perfect for me. What is the version of ESB you are working?
<rewrite>
<rewriterule>
<action value="customer1" regex="user1" type="replace" fragment="path"/>
</rewriterule>
</rewrite>
<send/>
I had the similar problem. In my case, I missed to set the outProperty back into REST_URL_POSTFIX after rewriting the url. Hope this can help someone having same problem in the future.
<sequence>
<property name="REST_URL_POSTFIX" expression="get-property('axis2','REST_URL_POSTFIX')"/>
<rewrite inProperty="REST_URL_POSTFIX" outProperty="REST_URL_POSTFIX">
<rewriterule>
<action fragment="path" type="replace" regex="^/soap/sms" value="/sms" />
</rewriterule>
</rewrite>
<property name="REST_URL_POSTFIX" scope="axis2" expression="get-property('REST_URL_POSTFIX')"/>
^^ Make sure to set this back ^^
</sequence>

freeswitch configuration for ipkall

i have setup my freeswitch with plivo but now i m unable to configure ipkall number for my sip user 1005#ipadress since the configuration of freeswitch wiki for ipkall is not clear.
Please can anybody give me steps to configure?
Thanks in advance.
in dialplan/public.xml (or an included file):
<include>
<extension name="IPKALL">
<condition field="destination_number" expression="^5150$">
<action application="set" data="domain_name=freeswitch.org"/>
<action application="transfer" data="1001 XML default"/>
</condition>
</extension>
</include>

Resources