Re: SipProvider.addSipListener()

Becky McElroy <[email protected]>
Newsgroups gmane.comp.voip.nist-sip
Message-ID <[email protected]>
[email protected] wrote:

> Ok so I’m stuck here. I am trying to use SipUnit to test a module that 
> also uses nist-sip. Since they are both running on the same IP, it 
> seems that nist-sip reuses the SipStack, which seems fair. However, in 
> my module I create a SipProvider and SipUnit also creates a 
> SipProvider. Both need SipListeners attached but I get a 
> TooManyListenersException. These are <different> SipProvider objects, 
> but when it iterates through the SipStack’s providers when adding a 
> new listener, it seems to make sure that ALL SipProviders only use the 
> same SipListener.
>
> I would have thought that each SipProvider could have it’s own 
> SipListener (but only 1).
>
>
> Am I doing something wrong or is there a better approach? Or do I have 
> to run my module in a different JVM?
>
> Andy Ochsner
>
> --If you think something's supposed to be difficult, you're less 
> likely to notice if you're doing it wrong.
>
>------------------------------------------------------------------------
>
>_______________________________________________
>nist-sip mailing list
>[email protected]
>http://www-x.antd.nist.gov/mailman/listinfo/nist-sip
>  
>
Hi Andy,

Well, it's more like: one nist-sip stack/listener per IP address.

Here's an answer from before where someone asked about this, and how I 
got around it (SipUnit example).
Hope this helps-
Becky

--------

The NIST stack is intended to be one per machine, which is fine in the 
real world. But as you pointed out, there are occasions where we need 
multiple sipstacks per machine.

We see 3 options for this:
a) use 2 ethernet cards with 2 IP addresses
b) configure multiple IP addresses on the same interface (linux allows 
it for sure, not sure about Windows)
c) in your SipUnit test code, when you create the stack 
(org.cafesip.sipunit.SipStack) that your test program will use, assign a 
valid alternative IP address (one that your real code isn't using - ie, 
if your real code is using 192.168.1.103 port 5060, then create the 
SipUnit stack with IP 127.0.0.1 port 5090 - you can define the 
Properties parameter before calling " new 
org.cafesip.sipunit.SipStack()" - there is an example of predefining the 
properties and passing them to the SipStack constructor in one or more 
of the example test classes). Then when your SipUnit program creates the 
SipPhone, pass to it as its proxy ip/port the real IP/port that your 
program under test uses (here, that would be 192.168.1.103 port 5060).

I tried the last option using one SipUnit test program where user a (on 
one SipStack) calls b (on another SipStack). and it worked. I defined it 
like this (it really only matters for the calling/originating side):

Properties properties1 = new Properties();
properties1.setProperty("javax.sip.IP_ADDRESS", "192.168.1.103"); ....

Properties properties2 = new Properties();
properties2.setProperty("javax.sip.IP_ADDRESS", "127.0.0.1"); ....

org.cafesip.sipunit.SipStack sipStack1 = new SipStack(null, 5060, 
properties1);
" .SipStack sipStack2 = new SipStack(null, 5090, properties2);

....

SipPhone ua = 
sipStack1.createSipPhone(properties2.getProperty("javax.sip.IP_ADDRESS"),
"udp", 5090, "sip:[email protected]");

.... (created ub same way in reverse, but for ub as the callee, it 
doesn't matter much)


then the rest of it is like the example tests that test both side (a 
calls b):
SipCall a = ua.createSipCall();
SipCall b = ub.createSipCall();
b.listenForIncomingCall();
...etc...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.