Forums Read-only archive

Dialplan plugin executed twice

8 posts · Brekeke SIP Server Forum

troelsmunch Original post
1. Brekeke Product Name and version: 2.0.7

2. Java version:Latest

3. OS type and the version:WIN2K3 R2

4. Your problem:

I know that this problem is discussed in another topic, but it seems to be a dead topic, and no solution has been found
http://www.brekeke-sip.com/bbs/viewtopi ... ight=twice

I have the following dialplan:
Matching:
$request=^INVITE
To=(.+)
$dialplan.findtonumber( To )=(.+)

Deploy:
$session=com.adp.dialplan.plugin.adpfordialplan %1
$target=myTarget
To=sip:45440\#%2@myTarget

As you can see I have a session plugin which handles the billing. In addition to that I have a dialplan plugin which modifies the destination number based on some internal rules of mine.
The problem is that the dialplan plugin
$dialplan.findtonumber( To )=(.+)
is called twice. I'm writing to a file within the plugin code, and from that I can conclude that the plugin is executed twice for each incomming call.
Does anyone know how to avoid this?

Thanks,
Troels
lakeview
Do you have another DialPlan rule definition which calls $dialplan.findtonumber? If so, disable it.
troelsmunch
lakeview wrote:Do you have another DialPlan rule definition which calls $dialplan.findtonumber? If so, disable it.
No I do not - this is the only rule.
lakeview
When you make a call to the SIP Server, how many sessions can you see in [Active Sessions] page?
troelsmunch
lakeview wrote:When you make a call to the SIP Server, how many sessions can you see in [Active Sessions] page?
One - only one.
lakeview
I tried it in my environment.. but my plug-in was called once.. it seems no problem.

if possible, paste your code here.
troelsmunch
Yes, here is the code in dialplan.findtonumber

Code:

    static public String findtonumber(String[] arg, com.brekeke.net.sip.SIPpacket sippacket, Properties pr) throws Exception
    {
        String strSIPto = stripCalleeURL(sippacket.getValue("To"));
        int iCallPatternID = Integer.parseInt(sippacket.getValue("X-callpatternid"));
        
        //Adding leading 0 to all Italian landline numbers
        if (iCallPatternID == 14848)
            strSIPto = ItalyLandline(strSIPto);
        try
        {
           FileWriter fil = new FileWriter("c:/ondo/test/" + evstat.callid  + "-findtonumber.txt", true);
            PrintWriter ud = new PrintWriter(fil);
            ud.println(strSIPto);
            ud.close();
         }
         catch (Exception e2)
         {
         }
        return strSIPto;
    }
In the output in the textfile I can see that there has been written twice for each call.

Thanks.
lakeview
Hi

I looked at the above source code and tried the same plug-in in my environment, but I did not get any issue.
It means the plug-in was executed once with a call and the text file was written once.

If you use a packet capture (e.g...Wireshark), how many INVITE can you see when you make a call?