Multiple stack instances works in version 1.2

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

I certainly don't want to complain about this... just want to understand 
it. I thought I saw someone say that in the new 1.2 stack version, 
multiple SipStack's on one box wouldn't work. However, it seems to work 
fine (I updated from CVS this past weekend).

 From my test program I can create two SipStacks, just like before, 
using two different sets of properties with different IP addresses and 
ports (same SipFactory used to create both stacks, a different listening 
point per stack, same SipListener listening to both). Everything gets 
created fine and messaging between two test phones (1 per stack) works 
fine, with or without a proxy inbetween.

Again, not to complain (this is great) but just want to know if this 
setup will continue to work as is, or can we expect it to break at some 
point.

Thanks,
Becky

______________________________________

public class TestTwoSipStacksNoProxy extends SipTestCase
{
    private static String IP_ADDRESS_1 = "127.0.0.1";
    private static String IP_ADDRESS_2 = "192.168.1.102";
   
    private SipStack sipStack1;
    private SipStack sipStack2;

    private SipPhone ua;

    private Properties properties1 = new Properties();
    private Properties properties2 = new Properties();

    public TestTwoSipStacksNoProxy(String arg0)
    {
        super(arg0);
       
        // when both stacks use same IP addr, get TooManyListenersException
        properties1.setProperty("javax.sip.IP_ADDRESS", IP_ADDRESS_1);
        properties1.setProperty("javax.sip.RETRANSMISSION_FILTER", "true");
        properties1.setProperty("javax.sip.STACK_NAME", "testAgent");
        properties1.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
        properties1.setProperty("gov.nist.javax.sip.DEBUG_LOG",
                "testAgent_debug.txt");
        properties1.setProperty("gov.nist.javax.sip.SERVER_LOG",
                "testAgent_log.txt");
        properties1.setProperty("gov.nist.javax.sip.READ_TIMEOUT", "1000");

        properties2.setProperty("javax.sip.IP_ADDRESS", IP_ADDRESS_2);
        properties2.setProperty("javax.sip.RETRANSMISSION_FILTER", "true");
        properties2.setProperty("javax.sip.STACK_NAME", "testAgent2");
        properties2.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "32");
        properties2.setProperty("gov.nist.javax.sip.DEBUG_LOG",
                "testAgent2_debug.txt");
        properties2.setProperty("gov.nist.javax.sip.SERVER_LOG",
                "testAgent2_log.txt");
        properties2.setProperty("gov.nist.javax.sip.READ_TIMEOUT", "1000");
    }

    /*
     * @see SipTestCase#setUp()
     */
    public void setUp() throws Exception
    {
        try
        {
            sipStack1 = new SipStack(null, 5060, properties1); // this 
would be org.cafesip.sipunit.SipStack
            sipStack2 = new SipStack(null, 5090, properties2); // ditto
        }
        catch (Exception ex)
        {
            fail("Exception: " + ex.getClass().getName() + ": "
                    + ex.getMessage());
            throw ex;
        }

        try
        {
            ua = sipStack1.createSipPhone("sip:[email protected]");
        }
        catch (Exception ex)
        {
            fail("Exception creating SipPhone: " + ex.getClass().getName()
                    + ": " + ex.getMessage());
            throw ex;
        }
    }

etc.
}


org.cafesip.sipunit.SipStack:

    /**
     * A constructor for this class. Before establishing any SIP sessions,
     * instantiate this class. You may provide the parameters for SIP 
protocol
     * binding on a specific TCP/UDP port, which will be used to communicate
     * with external SIP agents (a SIP proxy server, for example). A test
     * program may contain one or more SipStack objects, each of which 
may have
     * one or more SipPhones.
     *
     * @param proto
     *            SIP transport protocol, "tcp" or "udp" (default is "udp").
     * @param port
     *            port on which this stack listens for messages (default is
     *            5060).
     * @param props
     *            properties of the SIP stack. These properties are the 
same as
     *            that defined for JAIN-SIP SipStack. If this parameter 
has a
     *            null value, we pick default values for you.
     * @throws Exception
     */
    public SipStack(String proto, int port, Properties props) throws 
Exception
    {
        if (sipFactory == null)
        {
            sipFactory = SipFactory.getInstance();
            sipFactory.setPathName("gov.nist");
        }

        if (props == null)
        {
            props = defaultProperties;
        }

        if (props.getProperty("javax.sip.STACK_NAME") == null)
        {
            props.setProperty("javax.sip.STACK_NAME", "SipUnitTestAgent");
        }

        sipStack = sipFactory.createSipStack(props);

        headerFactory = sipFactory.createHeaderFactory();
        addressFactory = sipFactory.createAddressFactory();
        messageFactory = sipFactory.createMessageFactory();

        if (proto == null)
        {
            proto = DEFAULT_PROTOCOL;
        }

        if (port < 0)
        {
            port = DEFAULT_PORT;
        }

        ListeningPoint lp = sipStack.createListeningPoint(port, proto);

        sipProvider = sipStack.createSipProvider(lp);
        sipProvider.addSipListener(this);
    }

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.