Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
Hoe To URL Encode Webget request
Author Message
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Wed Apr 24, 2019 8:50 am    Post subject: Hoe To URL Encode Webget request Reply with quote

1. Brekeke Product Name and Version: Adv Ed 3.5.8

2. Java version:1.8

3. OS type and the version:RHEL7

4. UA (phone), gateway or other hardware/software involved:NA

5. Your problem:
How to URLEncode the webget request?
Back to top
View user's profile
Niloc
Brekeke Talented


Joined: 19 Sep 2017
Posts: 70
Location: NL

PostPosted: Wed Apr 24, 2019 11:10 am    Post subject: Reply with quote

Try $url.encode

FYI:
https://docs.brekeke.com/sip/url-decode
https://docs.brekeke.com/sip/url-encode
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Wed Apr 24, 2019 12:44 pm    Post subject: Reply with quote

Here is what I am trying:

Matching Patterns
$request = ^INVITE
$addr = ^192.168.2.10$
To = sip:(.+)@
Call-ID = (.+)
$url.encode($webget("http://192.168.2.11/log.php?num = %1&callid=%2")) = (.+)
Deploy Patterns
&my.logid = %3


%1 = +8005551212

But it shows up in the log.php as following:
GET[num] = ' 8005551212'

The plus sign is replaced with the empty space. I get the same value weather I use url.encode or not.

As a separate note, I also want to know the following 2 things:
1. shall I use $web.webget or $webget, is there any difference between them?
2. If there are multiple requests, does the webget keeps the socket open or it uses the new socket for each request?
3. If I have to send the request to a non standard port 8080, can I use like
$url.encode($webget("http://192.168.2.11:8080/log.php?num=%1&callid=%2")) = (.+)
Back to top
View user's profile
james
Brekeke Master Guru


Joined: 10 Dec 2007
Posts: 494

PostPosted: Thu Apr 25, 2019 11:54 am    Post subject: Reply with quote

Try like this.
Code:
$request = ^INVITE
$addr = ^192.168.2.10$
$url.encode($getSIPuser(To)) = (.+)
$url.encode(Call-ID) = (.+)
$webget("http://192.168.2.11/log.php?num=%1&callid=%2") = (.+)


> 1. shall I use $web.webget or $webget, is there any difference between them?

They are same. They call the same internal routine.


> 2. If there are multiple requests, does the webget keeps the socket open or it uses the new socket for each request?

It depends on situations, sockets are reused.

Set the [Multiple Dispatcher]=Yes at [Configuration]->[SIP] page.
It can execute $webget method concurrently.


> 3. If I have to send the request to a non standard port 8080, can I use like
> $webget("http://192.168.2.11:8080/log.php?num=%1&callid=%2")

Yes.
Also you can specify https if the web server supports it.



Is it for logging purpose?
If so, the CDR function might be an easier solution
https://docs.brekeke.com/sip/call-detailed-records-cdr-settings
https://docs.brekeke.com/sip/variables-for-cdr

Called number and Call-ID can be written to a file or DB if you specify the format as the following.
%{dstnamein},%{callidin}
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Tue Apr 30, 2019 3:18 pm    Post subject: Reply with quote

I turned on the dispatcher with 8 dispatcher under
Configuration-->SIP-->Performance Optimization

I restarted the BSS after the change. I ran the test again, I saw that there were some missing transaction on webserver (log.php). For each missing entry in the webserver log, I found one entry in the BSS sv log "In-Error-List", see one example below. Please explain what is the meaning of "In-Error-List".



webget: 04/30/19 19:51:23.087,http://192.168.2.11:8105/log.php?dnis=8005551212&callid=186-19731SIPP@192.168.2.5,,In-Error-List
Back to top
View user's profile
james
Brekeke Master Guru


Joined: 10 Dec 2007
Posts: 494

PostPosted: Tue Apr 30, 2019 7:18 pm    Post subject: Reply with quote

Can log.php handle multiple request concurrently?

If there is an error such as Timeout or Unknownhost with the specified URL, $webget method suspends the access to the same URL for a while.

During the suspending period, the method writes "In-Error-List" in the log if the same URL is requested.

It is 10sec (=10000ms) in the default.
You can tune the value with the variable "net.webget.timeout.retryafer".

For example, if you want to tune it to 500ms, set the line below at the [Configuration]->[Advanced] page.
Code:
  net.webget.timeout.retryafer = 500


FYI: the list of suspended URL will be shown by executing weberrorlist command at [Tools]-[Command] page.
https://docs.brekeke.com/sip/weberrorlist
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Wed May 01, 2019 8:28 am    Post subject: Reply with quote

Awesome, it was very helpful.
It would be nice if BSS dumps the error in the sv log as soon as it puts in the error list so we know what was the error.
What would be more helpful if it triggers an email on such errors.
Back to top
View user's profile
james
Brekeke Master Guru


Joined: 10 Dec 2007
Posts: 494

PostPosted: Wed May 01, 2019 10:33 am    Post subject: Reply with quote

> It would be nice if BSS dumps the error in the sv log as soon as it puts in the error list

I think it will be logged immediately as "Timeout" or "UnknownHost".

> What would be more helpful if it triggers an email on such errors.

You can write such a DialPlan rule with "$alert.message".
https://docs.brekeke.com/sip/alert-message
Back to top
View user's profile
james
Brekeke Master Guru


Joined: 10 Dec 2007
Posts: 494

PostPosted: Wed May 01, 2019 10:51 am    Post subject: Reply with quote

For example...

Rule-1: Access to log.php
Matching Patterns
$request = ^INVITE
$addr = ^192.168.2.10$
$url.encode($getSIPuser(To)) = (.+)
$url.encode(Call-ID) = (.+)
$webget("http://192.168.2.11/log.php?num = %1&callid=%2") = (.+)
Deploy Patterns
&my.logid = %3

Rule-2: Send Alert to Admin
Matching Patterns
$isNull("&my.logid") = ^true
Deploy Patterns
$alert.message = Can not access to log.php

If &my.logid is not set yet, the rule-2 sends an alert e-mail.

Note: you need to set the e-mail account at the [Email]->[Settings] beforehand.
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Wed May 01, 2019 12:26 pm    Post subject: Reply with quote

That is an awesome solution, thanks.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1