[asterisk-dev] [solved ?] Problem doing SIP/RTP with an Asterisk to another Asterisk that has PSTN card

Abelenda Diego diego.abelenda at domo-safety.com
Wed Aug 29 08:47:57 CDT 2012


Oh... I just realized I sent the precisions using another email address
that is probably blocked... So here are my findings in chronological
order :

On Wed, 29 Aug 2012 13:38:53 +0200
Abelenda Diego <diego.abelenda at gmail.com> wrote:

> On Wed, 29 Aug 2012 10:33:17 +0200
> Abelenda Diego <diego.abelenda at gmail.com> wrote:
> 
> > On Tue, 28 Aug 2012 15:19:13 +0200
> > Abelenda Diego <diego.abelenda at domo-safety.com> wrote:
> > 
> > > Hello,
> > > 
> > > I have something weird I am trying to make an application that
> > > does a dialog over the audio stream with a "server".
> > > 
> > > My test case is :
> > > 
> > > Asterisk_client -- SIP --> Asterisk_server -> Playback(audiofile)
> > > 
> > > My real case is :
> > > Asterisk_client -- SIP --> SIP_Provider(Asterisk) -- PSTN -->
> > > server
> > > 
> > > 
> > > My test case works without problem. But in the real case I don't
> > > get any audio stream.
> > > 
> > > I tried with Wireshark to see what happens and the only difference
> > > is that I get a 183 Progress Message from the server. But no
> > > stream begins. When I call the same SIP provider with Ekiga, the
> > > softphone sends some magic RTP packet (containing 0x00 only) and
> > > then the SIP provider starts sending the audio stream.
> > > 
> > > In the application I use ast_request_and_dial so the 183 progress
> > > is completely unseen. ast_request_and_dial returns no problem with
> > > state UP but when using ast_waitfor() I just wait until the
> > > timeout and get nothing (20sec timeout where I should get
> > > silence). As said before wireshark doesn't detect any RTP packet
> > > from the server to my Asterisk, and I send silence using
> > > silence_generator.
> > > 
> > > My Asterisk configuration look like this :
> > >     sip.conf :
> > > 	disallow=all
> > > 	allow=ulaw:50
> > > 	jbenable=no
> > > 	realm=domosafety.com
> > > 	dtmfmode=inband
> > > 
> > > 	[fakeserver]
> > > 	type=peer
> > > 	port=5060
> > > 	host=<host>
> > > 	username=<username>
> > > 	defaultuser=<username>
> > > 	fromuser=<username>
> > > 	touser=<username>
> > > 	secret=<password>
> > > 	canreinvite=yes
> > > 	context=ServerContext
> > > 	qualify=yes
> > > 	progressinband=yes
> > > 	insecure=invite,port
> > > 
> > > 	[realserver]
> > > 	type=peer
> > > 	port=5060
> > > 	host=<host>
> > > 	username=<username>
> > > 	defaultuser=<username>
> > > 	fromuser=<username>
> > > 	touser=<username>
> > > 	secret=<password>
> > > 	canreinvite=yes
> > > 	context=ServerContext
> > > 	qualify=yes
> > > 	progressinband=yes
> > > 	insecure=invite,port
> > >  
> > >     extensions.conf:
> > > 	[ServerContext]
> > > 	exten => realserver,1,Dial(SIP/<number>@realserver)
> > > 	exten => fakeservre,1,Dial(SIP/<number>@fakeserver)
> > > 
> > > 
> > > I am out of ideas as to why I have this problem... someone has
> > > some tip for me ?
> > > 
> > > I put everything that seemed related in my configuration but
> > > nothing changed.
> > > 
> > > Thank you in advance for any reply.
> > > 
> > > Best regards,
> > > Diego Abelenda
> > 
> > I have tried more and it seems it's not configuration related at
> > all. I explain :
> > 
> > my current extensions.conf is :
> > 	[Internal]
> > 	exten => realserver,1,Dial(SIP/<number>@realserver)
> > 	exten => fakeservre,1,Dial(SIP/<number>@fakeserver)
> > 	[Public]
> > 	exten => bridge,1,MyApplication(fakeserver,Internal, <args>)
> > 
> > and when in my .c file I use
> > 
> > 	outgoing = ast_request_and_dial("Local",
> > 	ast_best_codec(chan->nativeformats),
> > 	chan, extension_at_context, TIMEOUT,
> > 	&reason, S_COR(chan->caller.id.number.valid,
> > 		chan->caller.id.number.str, NULL)),
> > 	"MyApp");
> > 
> > and when the call returns I have a channel that is considered UP by
> > asterisk but I never get any audio even if I send something.
> > 
> > While when I change the extensions.conf to have :
> > 	[Public]
> > 	exten => bridge,1,Dial(Local/fakeserver at Internal)
> > it works I can talk in my phone and the other side receives.
> > 
> > So my question is : How should I setup the channel to have it
> > working ? I don't understand at all why it doesn't work using
> > ast_request_and_dial with these arguments.
> > 
> > Should I use ast_request and then set it up manually to call ? if
> > yes what should I set as options ?
> > 
> > I am really lost here and can't find any information in the API
> > documentation. And every other doc or website I find is either
> > Changelog or some website talking about how to use asterisk and so
> > not relevant to my problem.
> > 
> > Best regards,
> > Diego Abelenda
> 
> Finally !
> 
> I was right about the problem with ast_request_and_dial ... it doesn't
> support the 183 Progress semantics of SIP ... If I use
> 
> out = ast_request() 
> 
> and then use (simplified version) :
> 
> while (ast_waitfor(out, TIMEOUT) >= 0) {
> 	frame = ast_read(out);
> 	if (!frame)
> 		return -1;
> 	if (frame->type == AST_FRAME_CONTROL &&
> 			frame->subclass.integer ==
> AST_CONTROL_PROGRESS) silence_generator =
> 			ast_channel_start_silence_generator(out);
> }
> 
> And now I have a working channel!!
> 
> Is it a bug of ast_request_and_dial ?
> 
> I mean : the other server is an Asterisk too so it's kind of
> strange...
> 
> The document ( http://tools.ietf.org/id/draft-ietf-sip-183-00.txt )
> says nothing about needing to SEND audio to get the progress audio
> stream. And I have not found any accepted RFC talking about that. The
> 1XX codes should be completely optional if we follow the SIP RFC.
> 
> So I can understand the behaviour of ast_request_and_dial that
> completely ignores it. And not the other Asterisk that doesn't give
> any audio as a result.
> 
> Well at least what I wanted to do now works so I'm happy with it.
> 
> Best regards,
> Diego Abelenda





More information about the asterisk-dev mailing list