Hi Henning,

i assume that the example of the dispatcher.list is portable to any sql based dispatcher szenario.
Tried code=401 (was not working) and now class=4.

So now i am thinking, that is *never* possible to overwrite or add class/code szenarios for dispatcher targets.
And with that in mind, the module documentation with the "class=4" entry in dispatcher.list file is WRONG.

Tried that: 


        "SET":  {
          "ID": 1200,
          "TARGETS":  [{
              "DEST": {
                "URI":  "sip:TRUNK.DNSNAME.EXAMPLE;transport=tls",
                "FLAGS":  "IP",
                "PRIORITY": 0,
                "ATTRS":  {
                  "BODY": "socket=tls:XX.XX.XX.XX:5061;ping_from=sip:TRUNK.DNSNAME.EXAMPLE;class=4",
                  "DUID": "",
                  "MAXLOAD":  0,
                  "WEIGHT": 0,
                  "RWEIGHT":  0,
                  "SOCKET": "tls:XX.XX.XX.XX:5061"
                },
                "LATENCY":  {
                  "AVG":  22.099998,
                  "STD":  2.514403,
                  "EST":  22.099998,
                  "MAX":  27,
                  "TIMEOUT":  0
                }
              }
            }]
        }
      }]


Cheers Karsten

Am Mo., 16. Dez. 2019 um 15:23 Uhr schrieb Henning Westerholt <hw@skalatan.de>:

Hi Karsten,

 

have a look to the docs:

 

e.g. "class=2" would accept everything from 200 to 299 as valid response” – so that class 4 is probably everything from 400 – 499.

 

Cheers,

 

Henning

 

--

Henning Westerholt – https://skalatan.de/blog/

Kamailio services – https://gilawa.com

 

From: sr-users <sr-users-bounces@lists.kamailio.org> On Behalf Of Karsten Horsmann
Sent: Monday, December 16, 2019 1:01 PM
To: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Subject: Re: [SR-Users] OPTION pings with dispatcher to asterisk box

 

Hi Joel, hi List,

 

okay in asterisk i must add an correct match entry. But i am confused about the dispatcher documentation.

 

What means the class=4 in the attributes field? AFAIK from now, dispatcher OPTION pings cans be only configured global with modparam settings, 

same as you can only global enable or disable OPTION pinging.

 

Maybe some developers knows that example with "class=4" is meaning here. 

 

For database, each element of a line resides in a different column. Next is a dispatcher.list file example:

Example 1.50. dispatcher list file

...
#
# dispatcher destination sets (groups)
#
 
# line format
# setid(int) destination(sip uri) flags(int,opt) priority(int,opt) attributes(str,opt)
 
# proxies
2 sip:127.0.0.1:5080;transport=tcp 0 10 class=4;prefix=448;strip=2

 

Cheers

Karsten

 

Am Sa., 14. Dez. 2019 um 07:45 Uhr schrieb Karsten Horsmann <khorsmann@gmail.com>:

Hi Joel,

 

Ah the wrong seperator typo should be a problem. :) 

 

I would prefer to use class=2 as default and on special cases an additional code=404. 

 

And in dispatcher I wrote the seperator correctly. 

 

Will check that monday. 

 

Cheers 

Karsten 

 

Joel Serrano <joel@textplus.com> schrieb am Sa., 14. Dez. 2019, 03:26:

Hey Karsten, 

 

I'm using that same modparam and it's working as expected. My example:

 

modparam("dispatcher", "ds_ping_reply_codes", "class=2;code=403;code=488;code=405;class=3")

 

I believe the problem is that you are using a comma "," as separator, and the correct separator is a semi-colon ";"???

 

BTW (offtopic), to make Asterisk answer with a 200 OK, you can do the following:

 

Add to extensions.conf...

 

[default]
exten => s,1,Wait(1)
same => n,Hangup

 

This will make asterisk respond with a 200OK instead of a 404 Not Found. This "default" is dependent on the context= parameter in sip.conf, if you have changed it, you will have to name the extension accordingly. And lastly, AFAIR you don't need the wait(1) and probably can do the hangup() directly, I needed it for different reasons, give it a try.

 

This works for OPTIONS sent to a sip:IP:Port address, if you are using a monitoring system or cli tool or similar that sends OPTIONS to sip:something@ip:port, then the following dialplan works (I'll use "nagios" as an example: sip:nagios@X.X.X.X:5060) :

 

[default]
exten => nagios,1,Wait(1)
same => n,Hangup

 

You can combine both if you have both kinds:

 

[default]
exten => s,1,Wait(1)
same => n,Hangup

exten => nagios,1,Wait(1)
same => n,Hangup

 

etc....

 

 

Hope this helps!

 

Joel.

 

 

 

 

 

On Fri, Dec 13, 2019 at 8:35 AM Karsten Horsmann <khorsmann@gmail.com> wrote:

Hello all!

 

i am using kamailio 5.3.1-4 on CentOS and i am using dispatcher to ping his targets.

Now i have someone with asterisk that answers with 401 or 404 (depends on asterisk version).

 

So i tried  code=401;code=404 as aditional attrs. Seems not to work.

Also i tired to change the modparam from class=2 to this:

  modparam("dispatcher", "ds_ping_reply_codes", "class=2,code=401,code=404")  

 

Is that a "bug" or a hidden feature, or i missed something?

 

Btw - Have a nice weekend!

 

SELECT * FROM dispatcher WHERE id=1 \G
*************************** 1. row ***************************
         id: 1
      setid: 1100
destination: sip:SOMEWHERE;transport=tls
      flags: 0
   priority: 0
      attrs: socket=tls:MY.IP.AD.RR:5061;ping_from=sip:MY.SIP.DOMAIN;code=401;code=404
description: UNTRUSTED



        "SET":  {
          "ID": 1100,
          "TARGETS":  [{
              "DEST": {
                "URI":  "sip:SOMEWHERE;transport=tls",
                "FLAGS":  "IP",
                "PRIORITY": 0,
                "ATTRS":  {
                  "BODY": "socket=tls:MY.IP.AD.RR:5061;ping_from=sip:MY.SIP.DOMAIN;code=401;code=404",
                  "DUID": "",
                  "MAXLOAD":  0,
                  "WEIGHT": 0,
                  "RWEIGHT":  0,
                  "SOCKET": "tls:MY.SIP.DOMAIN:5061"
                },
                "LATENCY":  {
                  "AVG":  48768.816406,
                  "STD":  139490.953125,
                  "EST":  43359.566406,
                  "MAX":  568876,
                  "TIMEOUT":  8
                }
              }
            }]
        }
      }]

#!ifdef WITH_MYSQL
modparam("dispatcher", "db_url", "DBURL")
modparam("dispatcher", "table_name", "dispatcher")
#!endif
#!ifndef WITH_MYSQL
modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
#!endif
modparam("dispatcher", "ds_ping_method", "OPTIONS")
modparam("dispatcher", "ds_ping_from", "<sip:ping@FANCY-COMPANY-WEBNAME>")
modparam("dispatcher", "ds_ping_interval", 30)
modparam("dispatcher", "ds_probing_mode", 1)
modparam("dispatcher", "ds_probing_threshold", 2)
modparam("dispatcher", "setid_pvname", "$var(setid)")
modparam("dispatcher", "attrs_pvname", "$var(attrs)")
modparam("dispatcher", "ds_ping_reply_codes", "class=2,code=401,code=404")
modparam("dispatcher", "ds_ping_latency_stats", 1)


https://community.asterisk.org/t/asterisk-responds-with-404-to-options-even-when-an-endpoint-is-matched/76238




Dec 13 17:25:46 siptrunk3 /usr/sbin/kamailio[25115]: INFO: <script>: Sending message
'OPTIONS sip:SOMEWHERE;transport=tls SIP/2.0
Via: SIP/2.0/TLS MY.IP.AD.RR:5061;branch=z9hG4bK2527.825671c0000000000000000000000000.0
To: <sip:SOMEWHERE;transport=tls>
From: <sip:MY.SIP.DOMAIN>;tag=f9bf2579cb456ea8d260d4aabc8248ef-9ca844ad
CSeq: 10 OPTIONS
Call-ID: 01cb6e272da7b0dd-25115@MY.IP.AD.RR
Max-Forwards: 70
Content-Length: 0
User-Agent: SBC-OS

'
Dec 13 17:25:46 siptrunk3 /usr/sbin/kamailio[25127]: INFO: <script>: Received message
'SIP/2.0 404 Not Found
Via: SIP/2.0/TLS MY.IP.AD.RR:5061;branch=z9hG4bK2527.825671c0000000000000000000000000.0;received=MY.IP.AD.RR
From: <sip:MY.SIP.DOMAIN>;tag=f9bf2579cb456ea8d260d4aabc8248ef-9ca844ad
To: <sip:SOMEWHERE;transport=tls>;tag=as54adca41
Call-ID: 01cb6e272da7b0dd-25115@MY.IP.AD.RR
CSeq: 10 OPTIONS
Server: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Accept: application/sdp
Content-Length: 0

'

--

Cheers
*Karsten Horsmann*

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


 

--

Mit freundlichen Grüßen
*Karsten Horsmann*



--
Mit freundlichen Grüßen
*Karsten Horsmann*