Unable to locate Registered client Asterisk - Kamailio - asterisk

Problem: My main issue is that when I “REGISTER” a client via Kamailio, and I attempt to “Dial” a different endpoint within an Asterisk Dial Plan, Asterisk throws an error stating that the endpoint (the number I am dialing via “Dial”) is not registered or reachable. However, commands like “Playback” do work correctly for the client I “REGISTERED” via Kamailio.
E.g. I register client 10001 in Kamailio, I then register another client 10002 in Kamalio; both 10001 and 10002 can exercise an Asterisk Dial Plan which will play videos/audio (No Problem). But, now I want 10001 to Call (Dial) 10002; it is at this point that Asterisk throws the error “10002 is not registered or reachable”.
I have tried many of the suggestion on many different help boards (several times) but I am still unable to forward a registration from Kamailio to Asterisk.
With my current Kamailio configuration (I do use dispatching), I see , via tcpdump, Asterisk receiving a “REGISTER” request, and Asterisk sends back the “unauthorized” as expected, however, Kamailio does not re-send the “REGISTER” as is customary. I am not sure of the next step to take, but I feel I have a couple of options.
- I can continue to try and figure out why Kamailio is not sending the second “REGISTER” (I have not yet been able to figure this out).
- Tell Asterisk to not require authentication. (I am using pjsip and do not know how to not require authentication in Asterisk when the request is from Kamailio).
I have put a lot of time into this one, and I am at a sticking point. Any help or suggestions would be very much appreciated.
Thank you,

Kamailio is proxy. It SHOULD NOT do send second register unless you EXPLICTLY ask it do that in dialplan.
Dispatcher module is fast processing module. It should not do for you all staff, it just give you suggestion for dispatch.
You should not do check on asterisk for registration, you have send request to kamailio, and kamailio SHOULD do that work(it do much faster and HAVE info).
Main issue is:
asterisk main goal - give easy to understand platform for begginers. So anyone can get working pbx for free. It work on top level, with calls.
kamailio main goal is PERFOMANCE. It is not for begginer, you need have solid understanding of sip protocol, not just know that you want call. You have define what to do on packets level.

Related

How to get call on an extension, which is registered when a call towards it reach Kamailio

I am using Kamailio 4.4 as the proxy with my Asterisk server. I am trying to develop a scenario where an extension gets registered on asterisk via Kamailio when it receives a push notification. This push notification is sent to the sip extension when a call towards this extension reaches to the Kamailio.
For example, suppose there is two SIP extension( extension 1 and extension 2) registered on Asterisk via Kamailio. When a call from extension 1 reaches the asterisk, it forwards the INVITE request towards extension 2 via Kamailio.Kamailio will try to forward it to extension 2. suppose the extension 2 is not able to receive the INVITE request from Kamailio. When extension two receive a push notification, it will register on asterisk.
So I need to get the call on extension 2 through the new registration.
We are trying to simulate registration of extension to the asterisk when receiving the push notification.
First, we registered extension 2 and disconnected the network. Then we tried to register the same extension when a call from extension 1 reaches to Kamailio. This is a simulation of push-based registration since an extension that receives the push will attempt to register when an incoming call is received.
When asterisk sends INVITE request to Kamailio, it immediately responded with 100 trying provisional response. This 100 response by Kamailio towards asterisk prevents asterisk from re-transmitting the INVITE.
Then Kamailio tried to send and retransmit the packet to extension 2, which does not have network access. This extension 2 was on port number 24071. Even after successful registration(in port 59995) of the extension 2, Kamailio continued to transmit the packets to the old port.
After that, we have configured Kamailio in a way that it won't send an immediate provisional reply(100 trying ) for INVITE request.
Here Kamailio is not immediately sending 100 trying message to Asterisk. This forces Asterisk to re-transmit. Asterisk was found to retransmit the same packets. However, even after the successful registration of extension 2, asterisk continued to send the old invite to Kamailio not the new one to the latest port.
This is the problem for me since push relies on the INVITE reaching the phone at the correct port number.
So, is there other good approaches to solve this issue?
One thing I would like to try is modifying the pending INVITE request towards old registered port with the new port details when new registration reaches to Kamailio. Can I get the ongoing requests from Kamailio?
Please suggest a viable solution.
Almost any kamailio config availible do similar thing.
You have save into location and consult it when do call.
However if you need really scalable platform you SHOULD NOT forward register requests to asterisk at all.
If kamailio send invite to wrong port, likly that mean you have TWO records in location.

Asterisk DID switch to out outgoing trunk?

I have a toll free DID that users call to access my PBX service on an Asterisk box. The problem is; this DID comes only with a single channel so the system can only receive one call at a time. My initial idea was to simply get the caller ID of the incoming call, disconnect the caller and issue an automated call back to him to proceed with the call. This would free up my toll free number but could be confusing for the caller of course and also, there are issues where the caller calls from behind an extension. The best solution would be to somehow seemlessly switch the call to an outgoing trunk to reconnect the caller but now using my SIP trunk.
My question is; is there a way to do this in Asterisk (or I guess, does SIP somehow allow such operation)?
Thanks in advance.
That is called "callback".
Yes, you can do it. No, asterisk have no internal way do that and no way do it not noticable for user.

Rebus HTTP gateway and MSMQ health state

Let's say we have
Client node with HTTP gateway outbound service
Server node with HTTP gateway inbound service
I consider situation where MSMQ itself stops from some reason on the client node. In current implementation Rebus HTTP gateway will catch the exception.
What do you think about idea that instead of just catching, the MessageQueueException exception could be also sent to server node and put on error queue? (name of error queue could be gathered from headers)
So without additional infrastructure server would know that client has a problem so someone could react.
UPDATE:
I guessed problems described in the answer would be raised. I should have explained my scenario deeper :) Sorry about it. Here it is:
I'm going to modify HTTP gateway in the way that InboundService would be able to do both - Send and Receive messages. So the OutboundService would be the only one who initiate the connection(periodically e.g. once per 5 minutes) in order to get new messages from server and send its messages to server. That is because client node is not considered as a server but as a one of many clients which are behind the NAT.
Indeed, server itself is not interested in client health but I though that instead of creating separate alerting service on client side which would use HTTP gateway HTTP gateway code, the HTTP gateway itelf could do this since it's quite in business of HTTP gateway to have both sides running.
What if the client can't reach the server at all?
Since MSMQ would be dead I thought about using in-process standalone persistent queue object like that http://ayende.com/blog/4540/building-a-managed-persistent-transactional-queue
(just an example implementation, I'm not sure what kind of license it has)
to aggregate exceptions on client side until server is reachable.
And how often will the client notify the server that is has experienced an error?
I'm not sure about that part - I thought it could be related to scheduled time of message synchronization like once per 5 minutes but what in case there would be no scheduled time just like in current implementation (while(true) loop)? Maybe it could be just set by config?
I like to have a consistent strategy about handling errors which usually involves plain old NLog logging
Since client nodes will be in the Internet behind the NAT standard monitoring techniques won't work. I thought about using queue as NLog transport but since MSMQ would be dead it wouldn't work.
I also thought about using HTTP as NLog transport but on the server side it would require queue (not really, but I would like to store it in queue) so we are back to sbus and HTTP gateway...that kind of NLog transport would be de facto clone of HTTP gateway.
UPDATE2: HTTP as NLog transport (by transport I mean target) would also require client side queue like I described in "What if the client can't reach the server at all?" section. It would be clone of HTTP gateway embedded into NLog. Madness :)
All the thing is that client is unreliable so I want to have all the information about client on the server side and log it in there.
UPDATE3
Alternative solution could be creating separate service, which would however be part of HTTP gateway (e.g. OutboundAlertService). Then three goals would be fulfilled:
shared sending loop code
no additional server infrastructure required
no negative impact on OutboundService (no complexity of adding in-process queue to it)
It wouldn't take exceptions from OutboundService but instead it would check MSMQ perodically itself.
Yet other alternative solution would be simply using other than MSMQ queue as NLog target but that's ugly overkill.
Regarding your scenario, my initial thought is that it should never be the server's problem that a client has a problem, so I probably wouldn't send a message to the server when the client fails.
As I see it, there would be multiple problems/obstacles/challenges with that approach because, e.g. what if the client can't reach the server at all? And how often will the client notify the server that is has experienced an error?
Of course I don't know the details of your setup, so it's hard to give specific advice, but in general I like to have a consistent strategy about handling errors which usually involves plain old NLog logging and configuring WARN and ERROR levels to go the Windows Event Log.
This allows for setting up various tools (like e.g. Service Center Operations Manager or similar) to monitor all of your machines' event logs to raise error flags when someting goes wrong.
I hope I've said something you can use :)
UPDATE
After thinking about it some more, I think I'm beginning to understand your problem, and I think that I would prefer a solution where the client lets the HTTP listener in the other end know that it's having a problem, and then the HTTP listener in the other end could (maybe?) log that as an error.
Another option is that the HTTP listener in the other end could have an event, ReceivedClientError or something, that one could attach to and then do whatever is right in the given situation.
In your case, you might put a message in an error queue. I would just avoid putting anything in the error queue as a general solution because I think it confuses the purpose of the error queue - the "thing" in the error queue wouldn't be a message, and as such it would not be retryable etc.

How can a Pinoccio lead scout make a POST request to a remote server?

I'd like my Pinocc.io lead scout to make a POST request (e.g. to inform a remote service of an event that has been triggered).
Note that I don't want to listen to a constant stream the results (as detailed here) as I don't want to be constantly connected to the HQ (I'm going to enable the wi-fi connection only when required to minimize battery usage), and the events I'm detecting are infrequent.
I would have thought that this is a very common use case, yet I can find no examples of the lead scout POSTing any messages.
I posted the same message directly on the Pinoccio website and I got this answer from an Admin
Out of the gate, that's not supported via HQ. Mainly because to get as
real-time performance between API/HQ and a Lead Scout, it makes most
sense to leave a TCP socket open continually, and transfer data that
way. HTTP, as you know, requires a connection, setup, transfer, and
teardown upon each request.
However, doesn't mean you can't get it
working. In fact, you can do both if you wanted—leave the main TCP
socket connected to HQ, and have a separate TCP client socket connect
to any site/server you want and send whatever you like. It will
require a custom Bootstrap, but you can then expose any aspect of that
functionality to HQ/ScoutScript directly.
If you take a look at this code, that's the client object you'd use to open an HTTP connection.
So in a nutshell the lead scout cannot make a POST request. To do so you'll need to create a custom bootstrap (e.g. using the Arduino IDE).

Why can't I view Omegle's HTTP request/response headers?

I'm trying to write a small program that I can talk to Omegle strangers via command line for school. However I'm having some issues, I'm sure I could solve the problem if I could view the headers sent however if you talk to a stranger on Omegle while Live HTTP Headers (or a similar plug-in or program) is running the headers don't show. Why is this? Are they not sending HTTP headers and using a different protocol instead?
I'm really lost with this, any ideas?
I had success in writing a command line Omegle chat client. However it is hardcoded in C for POSIX and curses.
I'm not sure what exactly your problem is, maybe it's just something with your method of reverse engineering Omegle's protocol. If you want to make a chat client, use a network packet analyzer such as Wireshark (or if you're on a POSIX system I recommend tcpdump), study exactly what data is sent and received during a chat session and have your program emulate what the default web client is doing. Another option is to de-compile/reverse engineer the default web client itself, which would be a more thorough method but more complicated.

Resources