Our outbound calls through Twilio are all being dropped after 32 seconds (inbound calls are fine). The error we receive from Twilio is Error 32022 "Ack not received from your SIP endpoint." I have been going through tutorials and the RFC but I must really be missing something.
The calls are encrypted TLS. SIP ALG has been disabled in our gateway router and our Grandstream PBX is configured for NAT.
Any help is appreciated!
Here is the 200 OK and the ACK that never arrives:
<--- Received SIP response (1177 bytes) from TLS:54.172.60.2:5061 --->
SIP/2.0 200 OK
CSeq: 2218 INVITE
Call-ID: b9e1de31-ce44-4d34-b63b-4c8636e151bf
From: <sip:+13049487110#XXXX>;tag=814fce4e-a1dc-49c7-a917-59496ad182a7
To: <sip:+15132607811#xxxx.pstn.twilio.com>;tag=84858964_c3356d0b_d52c7a82-314f-4be6-88f4-e73110bdbdd8
Via: SIP/2.0/TLS 74.195.14.236:5061;received=74.195.14.236;rport=52191;branch=z9hG4bKPj42ac7abe-f4b7-40dc-a314-8c6a90584481;alias
Record-Route: <sip:54.172.60.2:5060;r2=on;lr;twnat=sip:74.195.14.236:52191>
Record-Route: <sip:54.172.60.2:5061;transport=tls;r2=on;lr;twnat=sip:74.195.14.236:52191>
Server: Twilio
Contact: <sip:172.25.75.195:5060>
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,NOTIFY
Content-Type: application/sdp
X-Twilio-CallSid: CAb39a1e013e6ad6c03bd5bd2827612646
X-Twilio-TlsPolicy: TLSv1.0+
Content-Length: 362
v=0
o=root 1866335776 1866335776 IN IP4 172. ...
<--- Transmitting SIP request (1010 bytes) to TLS:54.172.60.2:5061 --->
ACK sip:54.172.60.2:5061;transport=TLS SIP/2.0
Via: SIP/2.0/TLS 74.195.14.236:5061;rport;branch=z9hG4bKPj483e2dff-e510-4908-89ee-25ec200a4072;alias
From: <sip:+13049487110#XXXX>;tag=814fce4e-a1dc-49c7-a917-59496ad182a7
To: <sip:+15132607811#xxxx.pstn.twilio.com>;tag=84858964_c3356d0b_d52c7a82-314f-4be6-88f4-e73110bdbdd8
Call-ID: b9e1de31-ce44-4d34-b63b-4c8636e151bf
CSeq: 2218 ACK
Route: <sip:54.172.60.2:5061;transport=tls;lr;r2=on;twnat=sip:74.195.14.236:52191>
Route: <sip:54.172.60.2:5060;lr;r2=on;twnat=sip:74.195.14.236:52191>
...
The ACK request s addressed incorrectly: per 3261 with loose routing it should be addressed to the Contact URI, but sent to the topmost Route (built from the bottommost Record-Route, the route-set in your ACK appears to be correct). Correct the request URI for the ACK, that should help.
I'm trying to get SRTP going in my iOS application using PJSIP. I have TLS working and without SRTP I can make and receive calls. However with SRTP I'm getting this odd 488 error on the INVITE. It's not able to initialize the media.
I've read other articles mentioning about the codecs. But I've insured that the codes being used by my Asterisk server and those compiled with PJSIP library on my iOS app are the same. The only thing I'm seeing here is that I'm enabled the crypto and PJSIP isn't liking it. Any thoughts?
INVITE sip:[REDACTED]#[REDACTED]:47229;transport=TLS;ob SIP/2.0
Via: SIP/2.0/TLS [REDACTED]:5161;rport;branch=z9hG4bKPj8ea1a332-0748-438f-ae74-5d17b038891d;alias
From: "Test" <sip:asterisk#172.31.18.138>;tag=7c3663cb-b5f5-4762-8526-8425d18b2466
To: <sip:[REDACTED]#[REDACTED];ob>
Contact: <sip:asterisk#[REDACTED]:5161;transport=TLS>
Call-ID: f454ef36-01ea-4f29-9482-4a10768bf1b7
CSeq: 24942 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub, path
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: FPBX-AsteriskNOW-13.0.190.12(13.13.1)
Content-Type: application/sdp
Content-Length: 398
v=0
o=- 1582453973 1582453973 IN IP4 172.31.18.138
s=Asterisk
c=IN IP4 [REDACTED]
t=0 0
m=audio 11410 RTP/AVP 3 110 9 97 101
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:84m7hqGvMjTU21xzkhBS3RQpQQjJ+aep0VwSlhx+
a=rtpmap:3 GSM/8000
a=rtpmap:110 speex/8000
a=rtpmap:9 G722/8000
a=rtpmap:97 iLBC/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:60
a=sendrecv
--end msg--
19:10:11.601 pjsua_call.c .Incoming Request msg INVITE/cseq=24942 (rdata0x1421f0540)
19:10:11.603 tsx0x1421fe0a8 ...Transaction created for Request msg INVITE/cseq=24942 (rdata0x1421f0540)
19:10:11.603 tsx0x1421fe0a8 ..Incoming Request msg INVITE/cseq=24942 (rdata0x1421f0540) in state Null
19:10:11.603 tsx0x1421fe0a8 ...State changed from Null to Trying, event=RX_MSG
19:10:11.603 dlg0x1421fd8a8 ....Transaction tsx0x1421fe0a8 state changed to Trying
19:10:11.603 dlg0x1421fd8a8 ..UAS dialog created
19:10:11.603 dlg0x1421fd8a8 ..Module mod-invite added as dialog usage, data=0x141de7588
19:10:11.603 dlg0x1421fd8a8 ...Session count inc to 3 by mod-invite
19:10:11.603 inv0x1421fd8a8 ..UAS invite session created for dialog dlg0x1421fd8a8
19:10:11.603 dlg0x1421fd8a8 ...Session count inc to 3 by mod-pjsua
19:10:11.603 pjsua_media.c ..Call 0: initializing media..
19:10:11.603 pjsua_call.c ..Error initializing media channel: Not Acceptable Here [status=170488]
19:10:11.604 endpoint ..Response msg 488/INVITE/cseq=24942 (tdta0x1421fe800) created
19:10:11.604 dlg0x1421fd8a8 ...Sending Response msg 488/INVITE/cseq=24942 (tdta0x1421fe800)
19:10:11.606 tsx0x1421fe0a8 ...Sending Response msg 488/INVITE/cseq=24942 (tdta0x1421fe800) in state Trying
19:10:11.606 pjsua_core.c ....TX 429 bytes Response msg 488/INVITE/cseq=24942 (tdta0x1421fe800) to TLS [REDACTED]:5161:
SIP/2.0 488 Not Acceptable Here
Via: SIP/2.0/TLS [REDACTED]:5161;rport=5161;received=[REDACTED];branch=z9hG4bKPj8ea1a332-0748-438f-ae74-5d17b038891d;alias
Call-ID: f454ef36-01ea-4f29-9482-4a10768bf1b7
From: "Test" <sip:asterisk#172.31.18.138>;tag=7c3663cb-b5f5-4762-8526-8425d18b2466
To: <sip:[REDACTED]#[REDACTED];ob>;tag=5oFGceZO4ZaKpLFEg7piOrM7IV2yeDLT
CSeq: 24942 INVITE
Content-Length: 0
--end msg--
In case anyone else has this issue. I'll tell you what solved this for me.
On Asterisk in my endpoint (pjsip show endpoint myendpoint) setting I had media_encryption_optimistic set to true. When I set this to false everything started working.
I'm not sure why as the how to on asterisk stated to turn this on. But I confirmed at all traffic was indeed encrypted by using wireshark to check the actual voice data.
If anyone know why this would be the case that this needed to be set to false it would help me better understand this. But for now I'm up and running.
I had this error on PJSIP ios and I solved on my end after DISABLING "SRTP" or "S-RTP" or "Secure RTP" or "Secure Transport". I removed this for TLS configuration.
//acc_cfg.srtp_secure_signaling = 1;
//acc_cfg.use_srtp = PJMEDIA_SRTP_MANDATORY;
488 / Not Acceptable Here
I also get the same problem with my server, atlast i find the solution
by getting to know that it is because codec, use right codec or
disable codec works great for you.
I have a voip application for iOS based on pjsip 2.3.0.
The device in question runs iOS 9.3.4 and the problem also seem to happen on iOS 10 beta. It is connected to IPV6 wifi network created from macbook's nat64/dns64.
The client is able to register properly with our server and also has no trouble making outbound call in UDP mode ( Everything works fine in TCP ).
The trouble is with inbound call where it fails intermittently due to the following reason when responding to INVITE with 200 OK message even though it is able to send 100 TRYING successfully just before it.
pjsua_core.c ....
Sent:
2016-07-31T16:49:32.443
<srcipv6:port> -> <dstipv6:port>
1005
SIP/2.0 200 OK Via: SIP/2.0/UDP
--end msg--
tsx0x1401d82a8 ....Error sending Response msg
200/INVITE/cseq=95989621(tdta0x140866000): No route to host
....Transport error, terminating transaction. Err=120065 (No route to host)
pjsua_call.c .Error sending response: No route to host [status=120065]
APIException: API call '::pjsua_call_answer( CALL_REFERENCE,
PJSUA_SIP_RESPONSE_STATUS_OKAY, NULL, NULL )'
failed with result code = 120065 ('No route to host')
Note that this happens only intermittently. Once an inbound call succeeds after sending 200 OK to INVITE then the subsequent calls do succeed. The problem does not exist in IPV4 networks.
I also did a packet capture and found that there is no trace of 200 OK message in it even though pjsua_core.c's trace tells otherwise as seen above.
Sincerely welcome any inputs on how to proceed further or if there are any fixes.
Edit 1 :
I have managed to debug all the way from ::pjsua_call_answer to the method “sendto” () calledin pjlib/src/pj/sock_bsd.c
/*
* Send data.
*/
PJ_DEF(pj_status_t) pj_sock_sendto(pj_sock_t sock,
const void *buf,
pj_ssize_t *len,
unsigned flags,
const pj_sockaddr_t *to,
int tolen)
{
PJ_CHECK_STACK();
PJ_ASSERT_RETURN(len, PJ_EINVAL);
CHECK_ADDR_LEN(to, tolen);
*len = sendto(sock, (const char*)buf, (int)(*len), flags,
(const struct sockaddr*)to, tolen);
if (*len < 0)
return PJ_RETURN_OS_ERROR(pj_get_native_netos_error());
else
return PJ_SUCCESS;
}
sendto here returns -1 when trying to send 200 OK message alone in ipv6.
Hi I am a new bee in Erlang but managed to create a simple TCP server which accepts client in passive mode and displays message.
I spawn a new process every time new client connects to the server. Is there a way I could send message to the client using the process which gets spawned when client connects.
Here is code.
-module(test).
-export([startserver/0]).
startserver()->
{ok, ListenSocket}=gen_tcp:listen(1235,[binary,{active, false}]),
connect(ListenSocket).
connect(ListenSocket)->
{ok, UserSocket}=gen_tcp:accept(ListenSocket),
Pid=spawn(? MODULE, user,[UserSocket]),
gen_tcp:controlling_process(UserSocket, Pid),
connect(ListenSocket).
user(UserSocket)->
case gen_tcp:recv(UserSocket, 0) of.
{ok, Binary}->% Send basic message.
{error, closed}->% operation on close.
end.
Can I have some thing like if I do.
Pid!{"Some Message"}. And the message is send to the socket associated with the process with non blocking io,
You could try this tutorial for writing a TCP server using OTP principles: http://learnyousomeerlang.com/buckets-of-sockets#sockserv-revisited
If you use a gen_server instead of your connect loop, you can store the Pids in the state. Then you can use gen_server:cast/2 to send a message to one of the Pids.
The function you want to send a message to the client from the controlling process is gen_tcp:send(Socket, Message), so for example if you wanted to send a one off message on connection you could do this:
user(UserSocket)->
gen_tcp:send(UserSocket, "hello"),
case gen_tcp:recv(UserSocket, 0) of
{ok, Binary}->% Send basic message.
gen_tcp:send(UserSocket, "basic message"),
{error, closed}->% operation on close.
gen_tcp:send(UserSocket, "this socket is closing now"),
end.
I am having problem with 'spawn' in erlang, it seems processes just die after awhile. Here's the simple code:
-module(simple).
-export([server/1, client/1, owner/1, spawn_n/2, start/1, main/1]).
server(State) ->
receive
{request,Return_PID} ->
io:format("SERVER ~w: Client request recieved from ~w~n", [self(),Return_PID]),
NewState = State + 1,
Return_PID ! {hit_count,NewState},
server(NewState);
{server_owner,Owner_PID} ->
io:format("SERVER ~w: Owner request recieved from ~w~n", [self(), Owner_PID]),
Owner_PID ! {hit_count,State},
server(State);
reset ->
io:format("SERVER ~w: State reset to zero.~n", [self()]),
server(0)
end.
client(Server_Address) ->
Server_Address ! {request, self()},
receive
{hit_count,Number} ->
io:format("CLIENT ~w: Hit count was ~w~n", [self(),Number])
end.
owner(Server_PID) ->
timer:sleep(random:uniform(100)),
Server_PID ! {server_owner,self()},
receive
{hit_count,Number} when Number > 5 ->
io:format("OWNER: Hit count is ~w , reseting counter. ~n", [Number]),
Server_PID ! reset,
owner(Server_PID);
{hit_count,Number} when Number < 5 ->
io:format("OWNER ~w: Hit count was ~w~n", [self(), Number]),
owner(Server_PID)
end.
spawn_n(N, Server_PID) ->
if
N>0 ->
spawn(simple,client,[Server_PID]),
timer:sleep(random:uniform(100)),
spawn_n(N-1,Server_PID);
N==0 ->
io:format("Last client spawned. ~n")
end.
start(N) ->
Server_PID = spawn(simple,server,[0]),
spawn(simple,owner,[Server_PID]),
spawn(simple,spawn_n,[N,Server_PID]).
main([Arg]) ->
N = list_to_integer(atom_to_list(Arg)),
start(N),
init:stop().
Here's an example I get when running it:
erl -noshell -s simple main 20
SERVER <0.28.0>: Client request recieved from <0.31.0>
CLIENT <0.31.0>: Hit count was 1
SERVER <0.28.0>: Owner request recieved from <0.29.0>
SERVER <0.28.0>: Client request recieved from <0.32.0>
OWNER <0.29.0>: Hit count was 1
CLIENT <0.32.0>: Hit count was 2
SERVER <0.28.0>: Owner request recieved from <0.29.0>
SERVER <0.28.0>: Client request recieved from <0.33.0>
OWNER <0.29.0>: Hit count was 2
CLIENT <0.33.0>: Hit count was 3
SERVER <0.28.0>: Owner request recieved from <0.29.0>
SERVER <0.28.0>: Client request recieved from <0.34.0>
OWNER <0.29.0>: Hit count was 3
CLIENT <0.34.0>: Hit count was 4
SERVER <0.28.0>: Owner request recieved from <0.29.0>
SERVER <0.28.0>: Client request recieved from <0.35.0>
OWNER <0.29.0>: Hit count was 4
CLIENT <0.35.0>: Hit count was 5
SERVER <0.28.0>: Owner request recieved from <0.29.0>
SERVER <0.28.0>: Client request recieved from <0.36.0>
CLIENT <0.36.0>: Hit count was 6
SERVER <0.28.0>: Client request recieved from <0.37.0>
CLIENT <0.37.0>: Hit count was 7
SERVER <0.28.0>: Client request recieved from <0.38.0>
CLIENT <0.38.0>: Hit count was 8
SERVER <0.28.0>: Client request recieved from <0.39.0>
CLIENT <0.39.0>: Hit count was 9
SERVER <0.28.0>: Client request recieved from <0.40.0>
CLIENT <0.40.0>: Hit count was 10
SERVER <0.28.0>: Client request recieved from <0.41.0>
CLIENT <0.41.0>: Hit count was 11
SERVER <0.28.0>: Client request recieved from <0.42.0>
CLIENT <0.42.0>: Hit count was 12
SERVER <0.28.0>: Client request recieved from <0.43.0>
CLIENT <0.43.0>: Hit count was 13
SERVER <0.28.0>: Client request recieved from <0.44.0>
CLIENT <0.44.0>: Hit count was 14
SERVER <0.28.0>: Client request recieved from <0.45.0>
CLIENT <0.45.0>: Hit count was 15
SERVER <0.28.0>: Client request recieved from <0.46.0>
CLIENT <0.46.0>: Hit count was 16
SERVER <0.28.0>: Client request recieved from <0.47.0>
CLIENT <0.47.0>: Hit count was 17
SERVER <0.28.0>: Client request recieved from <0.48.0>
CLIENT <0.48.0>: Hit count was 18
{error_logger,{{2011,6,27},{12,57,8}},"~s~n",["Error in process <0.28.0> with ex
it value: {terminated,[{io,format,[<0.22.0>,\"SERVER ~w: Client request recieved
from ~w~n\",[<0.28.0>,<0.49.0>]]},{simple,server,1}]}\n"]}
I don't get it. The processes just die or something? It shouldnt terminate!
I am running on windows 7 if it might be something windows-related.
Thanks
EDIT: heres what happens by doing application:start(sasl). before:
C:\Program Files\erl5.8.4\bin>erl
Eshell V5.8.4 (abort with ^G)
1> application:start(sasl).
ok
=PROGRESS REPORT==== 27-Jun-2011::16:03:55 ===
supervisor: {local,sasl_safe_sup}
started: [{pid,<0.37.0>},
{name,alarm_handler},
{mfargs,{alarm_handler,start_link,[]}},
{restart_type,permanent},
{shutdown,2000},
{child_type,worker}]
2>
=PROGRESS REPORT==== 27-Jun-2011::16:03:55 ===
supervisor: {local,sasl_safe_sup}
started: [{pid,<0.38.0>},
{name,overload},
{mfargs,{overload,start_link,[]}},
{restart_type,permanent},
{shutdown,2000},
{child_type,worker}]
2>
=PROGRESS REPORT==== 27-Jun-2011::16:03:55 ===
supervisor: {local,sasl_sup}
started: [{pid,<0.36.0>},
{name,sasl_safe_sup},
{mfargs,
{supervisor,start_link,
[{local,sasl_safe_sup},sasl,safe
{restart_type,permanent},
{shutdown,infinity},
{child_type,supervisor}]
2>
=PROGRESS REPORT==== 27-Jun-2011::16:03:55 ===
supervisor: {local,sasl_sup}
started: [{pid,<0.39.0>},
{name,release_handler},
{mfargs,{release_handler,start_link,[]}}
{restart_type,permanent},
{shutdown,2000},
{child_type,worker}]
2>
=PROGRESS REPORT==== 27-Jun-2011::16:03:55 ===
application: sasl
started_at: nonode#nohost
2> simple:main(['20']).
ok
SERVER <0.42.0>: Client request recieved from <0.45.0>
3> CLIENT <0.45.0>: Hit count was 1
3> SERVER <0.42.0>: Owner request recieved from <0.43.0>
3> SERVER <0.42.0>: Client request recieved from <0.47.0>
3> OWNER <0.43.0>: Hit count was 1
3> CLIENT <0.47.0>: Hit count was 2
3> SERVER <0.42.0>: Owner request recieved from <0.43.0>
3> SERVER <0.42.0>: Client request recieved from <0.48.0>
3> OWNER <0.43.0>: Hit count was 2
3> CLIENT <0.48.0>: Hit count was 3
3> SERVER <0.42.0>: Owner request recieved from <0.43.0>
3> SERVER <0.42.0>: Client request recieved from <0.49.0>
3> OWNER <0.43.0>: Hit count was 3
3> CLIENT <0.49.0>: Hit count was 4
3> SERVER <0.42.0>: Owner request recieved from <0.43.0>
3> SERVER <0.42.0>: Client request recieved from <0.50.0>
3> OWNER <0.43.0>: Hit count was 4
3> CLIENT <0.50.0>: Hit count was 5
3> SERVER <0.42.0>: Owner request recieved from <0.43.0>
3> SERVER <0.42.0>: Client request recieved from <0.51.0>
3> CLIENT <0.51.0>: Hit count was 6
3> SERVER <0.42.0>: Client request recieved from <0.52.0>
3> CLIENT <0.52.0>: Hit count was 7
3> SERVER <0.42.0>: Client request recieved from <0.53.0>
3> CLIENT <0.53.0>: Hit count was 8
3> SERVER <0.42.0>: Client request recieved from <0.54.0>
3> CLIENT <0.54.0>: Hit count was 9
3> SERVER <0.42.0>: Client request recieved from <0.55.0>
3> CLIENT <0.55.0>: Hit count was 10
3> SERVER <0.42.0>: Client request recieved from <0.56.0>
3> CLIENT <0.56.0>: Hit count was 11
3> SERVER <0.42.0>: Client request recieved from <0.57.0>
3> CLIENT <0.57.0>: Hit count was 12
3> SERVER <0.42.0>: Client request recieved from <0.58.0>
3> CLIENT <0.58.0>: Hit count was 13
3> SERVER <0.42.0>: Client request recieved from <0.59.0>
3> CLIENT <0.59.0>: Hit count was 14
3> SERVER <0.42.0>: Client request recieved from <0.60.0>
3> CLIENT <0.60.0>: Hit count was 15
3> SERVER <0.42.0>: Client request recieved from <0.61.0>
3> CLIENT <0.61.0>: Hit count was 16
3> SERVER <0.42.0>: Client request recieved from <0.62.0>
3> CLIENT <0.62.0>: Hit count was 17
3> SERVER <0.42.0>: Client request recieved from <0.63.0>
3> CLIENT <0.63.0>: Hit count was 18
3> {error_logger,{{2011,6,27},{16,3,58}},"~s~n",["Error in proc
exit value: {terminated,[{io,format,[<0.23.0>,\"SERVER ~w: Cli
ved from ~w~n\",[<0.42.0>,<0.64.0>]]},{simple,server,1}]}\n"]}
The other answer is correct, but it doesn't explain why.
It's a tricky question, and the answer is (sort of) in your log output:
{error_logger,{{2011,6,27},{12,57,8}},"~s~n",["Error in process <0.28.0> with exit value: {terminated,[{io,format,[<0.22.0>,\"SERVER ~w: Client request recieved from ~w~n\",[<0.28.0>,<0.49.0>]]},{simple,server,1}]}\n"]}
The first clue is that io:format/3 exits with 'terminated' and some data.
Looking at the documentation and searching for terminated gives ... nothing. Looking inside io.erl gives us the answer though.
Line 456 and 462 of io.erl returns {error, terminated} when the io device is down. So now we know that io:format can potentially exit with status terminated. Looking further we can see that this return value turns into the above error message on line 74 (with context):
case request(Io, Request) of
{error, Reason} ->
[_Name | Args] = tuple_to_list(to_tuple(Request)),
{'EXIT',{undef,[_Current|Mfas]}} = (catch erlang:error(undef)),
MFA = {io, Func, [Io | Args]},
exit({conv_reason(Func, Reason),[MFA|Mfas]});
If you follow the call path for request/2 you will find that one possible branch is at the {error, terminated} mentioned earlier.
So, long story short, standard out is down.
Most likely since you killed your system with init:stop().
You are calling init:stop() immediately after your spawns. How are you going to make sure all your processes are properly finished? You probably need to block on receive in main and notify main process when others are done.