[SIP Beyond VoIP] SIPBeyondVoIP Digest, Vol 105, Issue 1

Alexey Nikitenko alexeynikitenko1927 at gmail.com
Fri Mar 15 01:25:12 CET 2019


I added a lines:

print(self.engine.incoming_requests)
self.engine.add_incoming_request('INFO')
print(self.engine.incoming_requests)

in the beginning of _NH_SIPApplicationDidStart method. As I can see, INFO
method was added in set of methods,  but no SIPIncomingRequestGotRequest or
even SIPEngineLog notifications handled.

> Keep in mind this only works for single-transaction out-of-dialog
requests. In dialog requests will always be handled in dialog and will not
generate an IncomingRequest object even if the method matches the ones in
engine.incoming_requests

How can I realize: is my INFO request connected with some dialog?
There is sequence of requests in Wireshark:
=> Request: INVITE
<= Status: 401 Unathorized
=> ACK
=> Request: INVITE
<= Status: 100 Trying
<= Request: INFO
=> Status: 500 Unhandled by dialog usages

Invite requests were sent by session object and I have to handle incoming
INFO request.




пт, 15 мар. 2019 г. в 01:05, <sipbeyondvoip-request at lists.ag-projects.com>:

> Send SIPBeyondVoIP mailing list submissions to
>         sipbeyondvoip at lists.ag-projects.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip
> or, via email, send a message with subject or body 'help' to
>         sipbeyondvoip-request at lists.ag-projects.com
>
> You can reach the person managing the list at
>         sipbeyondvoip-owner at lists.ag-projects.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of SIPBeyondVoIP digest..."
>
>
> Today's Topics:
>
>    1. Problem with SIP Simple SDK notification handling
>       (Alexey Nikitenko)
>    2. Re: Problem with SIP Simple SDK notification      handling (Dan
> Pascu)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 14 Mar 2019 21:47:48 +1000
> From: Alexey Nikitenko <alexeynikitenko1927 at gmail.com>
> To: sipbeyondvoip at lists.ag-projects.com
> Subject: [SIP Beyond VoIP] Problem with SIP Simple SDK notification
>         handling
> Message-ID:
>         <
> CAESrG6QL6PQpSR2-wUn7FZMzWuUeXbWPJhAYH-DmxJOnqg-Eug at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> I try to handle notifications in my simple sip application. I can handle
> many notifications connected with session, application end engine, but I
> can't handle notifications, connected with incoming and outgoing low-level
> requests.
>
> There is incoming INFO messages is session, I can see in Wireshark, but it
> not handled with _NH_SIPIncomingRequestGotRequest.
>
> Full listing of class:
>
> class SimpleCallApplication(SIPApplication):
>
> def __init__(self, number, password, server_ip, server_port, logger):
> SIPApplication.__init__(self)
> self.logger = logger
> self.ended = Event()
> self.session = None
> self.uri = None
> self.player = None
> self._wave_file = None
> self.number = number
> self.password = password
> self.domain = '{}:{}'.format(server_ip, server_port)
> self.number_with_domain = '{}@{}'.format(number, self.domain)
> self.notification_center = NotificationCenter()
> self.notification_center.add_observer(self)
>
> def call(self, uri, filename):
> self.uri = uri
> self._wave_file = filename
> self.start(FileStorage('config'))
>
> @run_in_green_thread
> def _NH_SIPApplicationDidStart(self, notification):
>
> acc = None
> try:
> acc = AccountManager().get_account(self.number_with_domain)
> except KeyError:
> pass
> if acc is not None:
> self.account = acc
> else:
> self.account = Account(self.number_with_domain)
>
> self.account.__setstate__({'password': self.password})
> self.account.enabled = True
> self.account.save()
>
> to = ToHeader(SIPURI.parse(self.uri))
> settings = SIPSimpleSettings()
> settings.audio.input_device = None
> settings.audio.output_device = None
> settings.save()
> self.player = WavePlayer(SIPApplication.voice_audio_mixer, self._wave_file,
> loop_count=1)
> try:
> lookup = DNSLookup()
> routes = lookup.lookup_sip_proxy(to.uri, ['udp']).wait()
> except DNSLookupError, e:
> print 'DNS lookup failed: %s' % str(e)
> else:
> self.session = Session(self.account)
> stream = AudioStream()
>
> self.session.connect(to, routes, [stream])
>
> def _NH_SIPSessionGotRingIndication(self, notification):
> print 'Ringing!'
> session = notification.sender
> session.send(struct.pack('>BBBB', 1, 2, 3, 4))
>
> def _NH_SIPSessionDidStart(self, notification):
> print 'Session started!'
> session = notification.sender
> audio_stream = session.streams[0]
> audio_stream.bridge.add(self.player)
> self.player.play()
>
> def _NH_SIPSessionDidFail(self, notification):
> print 'Failed to connect'
> self.stop()
>
> def _NH_SIPSessionWillEnd(self, notification):
> session = notification.sender
> audio_stream = session.streams[0]
> self.player.stop()
> audio_stream.bridge.remove(self.player)
>
> def _NH_SIPSessionDidEnd(self, notification):
> print 'Session ended'
> self.stop()
>
> def _NH_SIPApplicationDidEnd(self, notification):
> self.ended.set()
>
> def _NH_AudioStreamGotDTMF(self, notification):
> print 'DTMF detected! {}'.format(notification.data.__dict__)
>
> def _NH_SIPIncomingRequestGotRequest(self, notification):
> print 'Incoming request'
>
> def _NH_SIPInvitationGotSDPUpdate(self, notification):
> print 'SDP update: {}'.format(notification.sender.state)
>
> def _NH_SIPRequestDidEnd(self, notification):
> print 'request ended'
>
> def _NH_SIPEngineLog(self, notification):
> print 'got a log!'
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190314/7117451d/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Thu, 14 Mar 2019 17:05:24 +0200
> From: Dan Pascu <dan at ag-projects.com>
> To: SIP Beyond VoIP <sipbeyondvoip at lists.ag-projects.com>
> Subject: Re: [SIP Beyond VoIP] Problem with SIP Simple SDK
>         notification    handling
> Message-ID: <5D006E0E-3F65-4BF9-ADFA-C9001D9CAD56 at ag-projects.com>
> Content-Type: text/plain; charset=us-ascii
>
>
> On 14 Mar 2019, at 13:47, Alexey Nikitenko wrote:
>
> > I try to handle notifications in my simple sip application. I can handle
> many notifications connected with session, application end engine, but I
> can't handle notifications, connected with incoming and outgoing low-level
> requests.
>
> By default no request is handled as a low level request. In order to have
> some requests handled as low level ones you need to indicate that by
> passing incoming_requests=[list_of_method_names] as an argument to
> Engine.start
>
> If you use SIPApplication, it will start the engine without passing any
> incoming_requests. In that case you need to call add_incoming_request on
> the Engine after you got SIPApplicationDidStart to add them on the fly at
> runtime.
>
> Keep in mind this only works for single-transaction out-of-dialog
> requests. In dialog requests will always be handled in dialog and will not
> generate an IncomingRequest object even if the method matches the ones in
> engine.incoming_requests
>
> In this particular example you'll have to add
>
> self.engine.add_incoming_request('INFO')
>
> in the beginning of _NH_SIPApplicationDidStart
>
> Check the documentation here:
>
>
> http://old.sipsimpleclient.org/projects/sipsimpleclient/wiki/SipCoreApiDocumentation#IncomingRequest
>
> >
> > There is incoming INFO messages is session, I can see in Wireshark, but
> it not handled with _NH_SIPIncomingRequestGotRequest.
> >
> > Full listing of class:
> >
> > class SimpleCallApplication(SIPApplication):
> >
> >     def __init__(self, number, password, server_ip, server_port, logger):
> >         SIPApplication.__init__(self)
> >         self.logger = logger
> >         self.ended = Event()
> >         self.session = None
> >         self.uri = None
> >         self.player = None
> >         self._wave_file = None
> >         self.number = number
> >         self.password = password
> >         self.domain = '{}:{}'.format(server_ip, server_port)
> >         self.number_with_domain = '{}@{}'.format(number, self.domain)
> >         self.notification_center = NotificationCenter()
> >         self.notification_center.add_observer(self)
> >
> >     def call(self, uri, filename):
> >         self.uri = uri
> >         self._wave_file = filename
> >         self.start(FileStorage('config'))
> >
> >     @run_in_green_thread
> >     def _NH_SIPApplicationDidStart(self, notification):
> >
> >         acc = None
> >         try:
> >             acc = AccountManager().get_account(self.number_with_domain)
> >         except KeyError:
> >             pass
> >         if acc is not None:
> >             self.account = acc
> >         else:
> >             self.account = Account(self.number_with_domain)
> >
> >         self.account.__setstate__({'password': self.password})
> >         self.account.enabled = True
> >         self.account.save()
> >
> >         to = ToHeader(SIPURI.parse(self.uri))
> >         settings = SIPSimpleSettings()
> >         settings.audio.input_device = None
> >         settings.audio.output_device = None
> >         settings.save()
> >         self.player = WavePlayer(SIPApplication.voice_audio_mixer,
> self._wave_file, loop_count=1)
> >         try:
> >             lookup = DNSLookup()
> >             routes = lookup.lookup_sip_proxy(to.uri, ['udp']).wait()
> >         except DNSLookupError, e:
> >             print 'DNS lookup failed: %s' % str(e)
> >         else:
> >             self.session = Session(self.account)
> >             stream = AudioStream()
> >
> >             self.session.connect(to, routes, [stream])
> >
> >     def _NH_SIPSessionGotRingIndication(self, notification):
> >         print 'Ringing!'
> >         session = notification.sender
> >         session.send(struct.pack('>BBBB', 1, 2, 3, 4))
> >
> >     def _NH_SIPSessionDidStart(self, notification):
> >         print 'Session started!'
> >         session = notification.sender
> >         audio_stream = session.streams[0]
> >         audio_stream.bridge.add(self.player)
> >         self.player.play()
> >
> >     def _NH_SIPSessionDidFail(self, notification):
> >         print 'Failed to connect'
> >         self.stop()
> >
> >     def _NH_SIPSessionWillEnd(self, notification):
> >         session = notification.sender
> >         audio_stream = session.streams[0]
> >         self.player.stop()
> >         audio_stream.bridge.remove(self.player)
> >
> >     def _NH_SIPSessionDidEnd(self, notification):
> >         print 'Session ended'
> >         self.stop()
> >
> >     def _NH_SIPApplicationDidEnd(self, notification):
> >         self.ended.set()
> >
> >     def _NH_AudioStreamGotDTMF(self, notification):
> >         print 'DTMF detected! {}'.format(notification.data.__dict__)
> >
> >     def _NH_SIPIncomingRequestGotRequest(self, notification):
> >         print 'Incoming request'
> >
> >     def _NH_SIPInvitationGotSDPUpdate(self, notification):
> >         print 'SDP update: {}'.format(notification.sender.state)
> >
> >     def _NH_SIPRequestDidEnd(self, notification):
> >         print 'request ended'
> >
> >     def _NH_SIPEngineLog(self, notification):
> >         print 'got a log!'
> > _______________________________________________
> > SIPBeyondVoIP mailing list
> > SIPBeyondVoIP at lists.ag-projects.com
> > http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip
>
>
> --
> Dan
>
>
>
>
>
>
> ------------------------------
>
> _______________________________________________
> SIPBeyondVoIP mailing list
> SIPBeyondVoIP at lists.ag-projects.com
> http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip
>
>
> End of SIPBeyondVoIP Digest, Vol 105, Issue 1
> *********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190315/557b9197/attachment-0001.html>


More information about the SIPBeyondVoIP mailing list