Hoe To URL Encode Webget request
Moderator: Brekeke Support Team
Hoe To URL Encode Webget request
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?
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?
Try $url.encode
FYI:
https://docs.brekeke.com/sip/url-decode
https://docs.brekeke.com/sip/url-encode
FYI:
https://docs.brekeke.com/sip/url-decode
https://docs.brekeke.com/sip/url-encode
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")) = (.+)
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")) = (.+)
Try like this.
> 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-detai ... r-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}
Code: Select all
$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") = (.+)
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-detai ... r-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}
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=8 ... Error-List
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=8 ... Error-List
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.
FYI: the list of suspended URL will be shown by executing weberrorlist command at [Tools]-[Command] page.
https://docs.brekeke.com/sip/weberrorlist
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: Select all
net.webget.timeout.retryafer = 500
https://docs.brekeke.com/sip/weberrorlist
> 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
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
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.
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.