Hello Craftsmen Asterisk,
I have a problem I can not extract in the variable from SipHeader.
I followed with dump I'm getting:
Diversion: <sip:+4917645615686#public-vip.cisco.de>;reason=unconditional
Diversion: "Anonymous"sip<:Anonymous#47.23.21.9>;reason=unknow;privacy=full;counter=1
I set in dialplan:
same => n,Set(diversion=${SIP_HEADER(Diversion))
recived:
sip:+4917645615686#public-vip.cisco.de>;reason=unconditional
but I also need the second row!
Diversion: "Anonymous"sip<:Anonymous#47.23.21.9>;reason=unknow;privacy=full;counter=1
Can someone help me?
Maybe you should read help and use second param?
pro-sip*CLI> core show function SIP_HEADER
-= Info about function 'SIP_HEADER' =-
[Synopsis]
Gets the specified SIP header from an incoming INVITE message.
[Description]
Since there are several headers (such as Via) which can occur multiple times,
SIP_HEADER takes an optional second argument to specify which header with that
name to retrieve. Headers start at offset '1'.
Please observe that contents of the SDP (an attachment to the SIP request)
can't be accessed with this function.
[Syntax]
SIP_HEADER(name[,number])
[Arguments]
number
If not specified, defaults to '1'.
[See Also]
Not available
Related
I'm using phpagi $agi->get_data to read digit from user.
In some telephones, user didn't hit any key, but audio playback immediately stops and get result of "D" !!
I searched a lot about it, and looks like $agi-get_dat receives DTMF data that contains 0-9*#ABCD.
1st question is, why my users get "D" without hitting any key!
2nd question is, how can i ignore these characters to prevent interrupting my ivr.
phpagi getdata do this call
https://wiki.asterisk.org/wiki/display/AST/AGICommand_stream+file
so you can extend it by adding allowed digits param. PhpAGI lib is opensource and have source code.
Actualy you can just use stream_file call
stream_file (line 677)
Play the given audio file, allowing playback to be interrupted by a
DTMF digit. This command is similar to the GET DATA command but this
command returns after the first DTMF digit has been pressed while GET
DATA can accumulated any number of digits before returning.
return: see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no digit received,
otherwise a decimal value of the DTMF tone. Use chr() to convert to
ASCII.
link: http://www.voip-info.org/wiki-stream+file
example: Ping an IP address
array, stream_file (string $filename, [string $escape_digits = ''],
integer $offset)
string $filename: without extension, often in /var/lib/asterisk/sounds
string $escape_digits
integer $offset
you can check the logs by the following command :
asterisk -vvvvv
and you can check the value of the input for example in php code :
$val = $agi->get_data
exec("echo $val >> /tmp/output")
and then check this file : /tmp/output
I'm programming a service with a team. The service receives a file as a byte array and returns a response. We are expecting a specific type of file (PDF, WORD, EXCEL, TXT, etc)
We are discussing what type of exception throws if the file is corrupted or invalid (a 0 bytes PDF file for example).
We are using gRPC as the communication protocol, so I'm thinking in return an Invalid Argument status code, but some coworker disagrees with me and proposes to use the Unknown status code.
Which scenarios allow me to use the Invalid Argument status code?
UNKNOWN should be reserved for cases when you don't know what sort of failure happened; this normally happens when converting errors from one type to another and it isn't clear what the original error implied.
INVALID_ARGUMENT's documentation:
// The client specified an invalid argument. Note that this differs
// from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments
// that are problematic regardless of the state of the system
// (e.g., a malformed file name).
That's exactly the case presented here, where the server does not consider the input valid.
I need to reuse value which is generated for my previous request.
For example, at first request, I make a POST to the URL /api/products/{UUID} and get HTTP response with code 201 (Created) with an empty body.
And at second request I want to get that product by request GET /api/products/{UUID}, where UUID should be from the first request.
So, the question is how to store that UUID between requests and reuse it?
You can use the Request Sent Dynamic values https://paw.cloud/extensions?extension_type=dynamic_value&q=request+send these will get the value used last time you sent a requst for a given request.
In your case you will want to combine the URLSentValue with the RegExMatch (https://paw.cloud/extensions/RegExMatch) to first get the url as it was last sent for a request and then extract the UUID from the url.
e.g
REQUEST A)
REQUEST B)
The problem is in your first requests answer. Just dont return "[...] an empty body."
If you are talking about a REST design, you will return the UUID in the first request and the client will use it in his second call: GET /api/products/{UUID}
The basic idea behind REST is, that the server doesn't store any informations about previous requests and is "stateless".
I would also adjust your first query. In general the server should generate the UUID and return it (maybe you have reasons to break that, then please excuse me). Your server has (at least sometimes) a better random generator and you can avoid conflicts. So you would usually design it like this:
CLIENT: POST /api/products/ -> Server returns: 201 {product_id: UUID(1234...)}
Client: GET /api/products/{UUID} -> Server returns: 200 {product_detail1: ..., product_detail2: ...}
If your client "loses" the informations and you want him to be later able to get his products, you would usually implement an API endpoint like this:
Client: GET /api/products/ -> Server returns: 200 [{id:UUID(1234...), title:...}, {id:UUID(5678...),, title:...}]
Given something like this, presuming the {UUID} is your replacement "variable":
It is probably so simple it escaped you. All you need to do is create a text file, say UUID.txt:
(with sample data say "12345678U910" as text in the file)
Then all you need to do is replace the {UUID} in the URL with a dynamic token for a file. Delete the {UUID} portion, then right click in the URL line where it was and select
Add Dynamic Value -> File -> File Content :
You will get a drag-n-drop reception widget:
Either press the "Choose File..." or drop the file into the receiver widget:
Don't worry that the dynamic variable token (blue thing in URL) doesn't change yet... Then click elsewhere to let the drop receiver go away and you will have exactly what you want, a variable you can use across URLs or anywhere else for that matter (header fields, form fields, body, etc):
Paw is a great tool that goes asymptotic to awesome when you explore the dynamic value capability. The most powerful yet I have found is the regular expression parsing that can parse raw reply HTML and capture anything you want for the next request... For example, if you UUID came from some user input and was ingested into the server, then returned in a html reply, you could capture that from the reply HTML and re-inject it to the URL, or any field or even add it to the cookies using the Dynamic Value capabilities of Paw.
#chickahoona's answer touches on the more normal way of doing it, with the first request posting to an endpoint without a UUID and the server returning it. With that in place then you can use the RegExpMatch extension to extract the value from the servers's response and use it in subsequent requests.
Alternately, if you must generate the UUID on the client side, then again the RegExpMatch extension can help, simply choose the create request's url for the source and provide a regexp that will strip the UUID off the end of it, such as /([^/]+)$.
A third option I'll throw out to you, put the UUID in an environment variable and just have all of your requests reference it from there.
I did create a simple testcase in JMeter.
Open a form and all it's content (css, images etc) :
GET /
GET /css/site.css
GET /favicon.ico
GET /fonts/specific-fonts.woff
GET /images/banner.png
Wait a little...
Post the values
POST /
Receive the "Thank You" page.
- GET /thanks
In the response on the first GET is a hidden input field which contains a token. This token needs to be included in the POST as well.
Now I use the "Regular Expression Extractor" of JMeter to get the token from the response. So far, so good.
Then, after retreiving all the other contents I create the POST message, using the variable name in the RegExp-Extractor in the value field of the token parameter.
But... when executing the testcase it fills in the default value given and not the actual value of the token.
So... first step in debugging this issue was to add a dummy-HTTP-GET request directly after I get the token. In this GET request I also add the token parameter with the token variable as value, but now I can easily check the parameter by looking at the access-log on my webserver.
In this case... the URL looks promising. It contains the actual token value in the GET, but it still uses the default value in the POST.
Second step in debugging was to use the "Debug Sampler" and the "View Results Tree".
By moving the Debug Sampler between the different steps I found out the value of the token-variable is back to the default value after I receive the CSS.
So... now the big question is...
How can I make JMeter to remember my variable value until the end of my test-script ?
JMeter doesn't "forget" variables. However variables scope is limited to the current Thread Group. You can convert JMeter variable to JMeter Property which have "global" scope by i.e. using Beanshell Post Processor with the following code:
props.put("myVar", vars.get("myVar"));
Or by using __setProperty() function. See How to Use Variables in Different Thread Groups guide for details.
As you found it your problem comes from a misunderstanding of scoping rules in jmeter.
https://jmeter.apache.org/usermanual/test_plan.html#scoping_rules
In your case, just put the post processor of the request that will give you the response containing the child node.
Also I think you don't need to share this token with other threads so don't use properties as proposed in the alternate answer.
in Network managment systems
using *SNMP version 1 *
if i am requesting for any object and am using GetRequest(..)
how it will work if many errors happens in the responce message ?
and how to represent it using error index ?
please remember that error index is used to identify and specify which Variable has the error i.e one error >>
You don't. The error-status and error-index fields should indicate the first variable that was unable to be retrieved due the error indicated by error-status. To determine that any of the remaining variables are also unable to be retrieved, the indicated error needs to be corrected (e.g. variable removed from the request, OID corrected, etc.) and the request re-sent. At that point, the error-status and error-index of the response would indicate the next variable with an error (if any).