Author Topic: Parrallel resolving any REGISTER packets  (Read 444036 times)

ivanov_ke

  • Newbie
  • *
  • Posts: 6
    • View Profile
Parrallel resolving any REGISTER packets
« on: January 21, 2014, 11:08:17 AM »
After some tests I found one problem that is important for me

EXTMODULE cannot resolve two different packets in one time if one of them resolves slowly

I created two PHP modules both catches "user.unregister"
And if i paste sleep on one of this SECOND Register packet waits 1st php module and dont use 2nd php module

Then i pasted sleep to  YateSIPEndPoint::regReq - same situation(


Can YATE resolve two REGISTER packets parrallel of 1st request slowly resolves by php module - or only in series?

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #1 on: January 22, 2014, 02:25:45 AM »
extmodule will serialize messages for a single script, so, yes, a php script is not multi threaded.

sip will send user.(un)register using a separate thread so the sip module processes register asynchronously.

2 php scripts should process asynchronously.
Can you attach a log to show your issue?
The log should include the messages:
yate.conf:
[general]
msgsniff=yes

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #2 on: January 22, 2014, 02:50:27 AM »
I checked again: you can't use php in this way.

The first script will install a handler for user.unregister, the second one will also install a handler for it.
The first handler will be always called by yate engine before the second one.
A second user.unregister message will always wait for the first one to be handled.

If you want to asychronously handle the same message you must:
1. Write a c++ module
2. Use javascript:
- You can set a filter for handled message's parameter
- Each instance will set the filter to a different value
- You can catch the message in regexroute before javascript and rotate the filter parameter value. This way you can distribute the processing. Each script will handle messages one by one
If you want a real multithreaded handling you need a c++ module



ivanov_ke

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #3 on: January 22, 2014, 05:28:16 AM »
Thank you,

about C++
I debugged by "Debug() and sleep()"
And I see that " YateSIPEndPoint::regRun" runs in series - no parallel

May be it processed parallel in next steps?(in functions that calls after)

ivanov_ke

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #4 on: January 22, 2014, 06:45:01 AM »
found method
AuthHandler::received -
it recieves messages async(parallel)

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #5 on: January 23, 2014, 01:59:00 AM »
regRun() is called from regReq() -> sync process and from YateSIPRegister::run() -> async process.

ivanov_ke

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #6 on: January 29, 2014, 04:27:58 AM »
What is filter in JavaScript, where it configure

cannot find it as documentation on yate.null.ro

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #7 on: January 31, 2014, 03:01:35 AM »
In javascript you can install handlers using a message parameters:

Message.install(func,"user.register",90,"param_name","param_value");

This will install a handler for user.register with priority 90.
The handler will be called only if the message will carry a parameter 'param_name' with value 'param_value'.

You can run 2 scripts, the first may install the handler for, let's say, a parameter instance=1 and the second for instance=2.
From outside, maybe regexroute or another java script you can install a handler for user.register to be handled before the ones with filters.
There you can rotate the instance parameter to distribute the handling.

ivanov_ke

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #8 on: January 31, 2014, 04:17:51 AM »
Thank you,

but i cannot understand work of JS dispetcher.

Register is message that waits answer - that means that dispetcher need wait everyone Resolver(that catches param=1, param=2, etc.) to send answer to YateEngine.

or it can only redirect message as another message
or change message parameters and Ack it and "handled = false" for catching it then of needed Resolver(param=n)

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Parrallel resolving any REGISTER packets
« Reply #9 on: February 03, 2014, 07:42:36 AM »
I don't understand you post. Can you rephrase it?

When you install a message handler you don't return the result to yate engine, you return it to message dispatcher.
In our case the result is returned to sip module.