无法在Java中实例化缺少的javax.sip.STACK_NAME属性和gov.nist.javax.sip.SipStackImpl

时间:2018-07-25 13:18:42

标签: java exception sip jain-sip

我想连接到另一台服务器上的sip服务器,注册然后搜索表单。

我正在尝试使用Jain-Sip框架在Java表单上注册。但是,在更基本的设置中,创建Sip Stack时遇到错误,并且无法传递它。

我使用Maven基础结构来构建应用程序

  • jain-sdp-1.0.1111.jar
  • jain-sdp-src-1.0.1111.jar
  • jain-sip-api-1.2.jar
  • jain-sip-api-1.2-src.jar
  • jain-sip-ri-1.2.1111.jar
  • jain-sip-sdp-1.2.1111.jar
  • jain-sip-src-1.2.1111.jar
  • jain-sip-tck-1.2.1111.jar
  • jain-sip-unit-test-1.2.1111。
  • log4j-1.2.17.jar

我添加了库。 库中文件的名称有时以javax.sip开头,有时以gov.nist.javax开头。

在表格的开头,我选择了饮者因子实例并输入了属性。具体来说,当我如下所示输入STACK_NAME或单纯形输入javax.sip时,

this.properties.put ("javax.sip.STACK_NAME", "Phone");
 this.properties.setProperty ("gov.nist.javax.sip.STACK_NAME", "Phone");

与“ javax.sip.PeerUnavailableException相比出错:对等SIP堆栈:javax.sip.javax.sip.SipStackImpl无法实例化。

当我仅输入gov.nist时,会出现“缺少javax.sip.STACK_NAME属性”错误。

如果我只离开javax.SipStackNmae,则在Listining点中输入IP端口和传输信息时,会收到“无法分配请求地址:未绑定”错误。

我检查了此错误的端口。我关闭了使用相同端口进行端口重叠的应用程序。但是它还没有改善。此错误是由服务器所在的IP地址引起的。 5060端口无法连续发送连接请求。

     private void onOpen(java.awt.event.WindowEvent evt) {                        

    try {
        // Get the local IP address.
        this.ip = "185.224.184.100";
        // Create the SIP factory and set the path name.
        this.sipFactory = SipFactory.getInstance();
        this.sipFactory.setPathName("gov.nist");
        // Create and set the SIP stack properties.
        this.properties = new Properties();

        this.properties.put("javax.sip.STACK_NAME", "Mobicents-SIP-Servlets");
        this.properties.setProperty("javax.sip.TRACE_LEVEL", "32");
        //this.properties.setProperty("gov.nist.javax.sip.STACK_NAME", "Mobicents-SIP-Servlets");
        this.properties.setProperty("javax.sip.IP_ADDRESS", this.ip); 
        this.properties.setProperty("javax.sip.MAX_MESSAGE_SIZE", "1048576");
        this.properties.setProperty("javax.sip.DEBUG_LOG", "xDebug.txt");
        this.properties.setProperty("javax.sip.SERVER_LOG", "xLog.txt");

        // Drop the client connection after we are done with the transaction.
        this.properties.setProperty("javax.sip.CACHE_CLIENT_CONNECTIONS", "false");

        this.properties.setProperty("javax.sip.LOG_MESSAGE_CONTENT", "true");

        this.properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off");
        this.properties.setProperty("javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true");
        this.properties.setProperty("javax.sip.THREAD_POOL_SIZE", "64");
        this.properties.setProperty("javax.sip.REENTRANT_LISTENER", "true");
        this.properties.setProperty("javax.sip.MAX_FORK_TIME_SECONDS", "0 ");
        this.properties.setProperty("javax.sip.AUTOMATIC_DIALOG_ERROR_HANDLING", "false");

        sipStack = sipFactory.createSipStack(properties);
        System.out.println("sipStack = " + sipStack);

        // Create the SIP stack.
        this.sipStack = this.sipFactory.createSipStack(this.properties);
        // Create the SIP message factory.
        this.messageFactory = this.sipFactory.createMessageFactory();
        // Create the SIP header factory.
        this.headerFactory = this.sipFactory.createHeaderFactory();
        // Create the SIP address factory.
        this.addressFactory = this.sipFactory.createAddressFactory();
        // Create the SIP listening point and bind it to the local IP address, port and protocol.
        this.listeningPoint = this.sipStack.createListeningPoint(this.ip, this.port, this.protocol);
        // Create the SIP provider.
        this.sipProvider = this.sipStack.createSipProvider(this.listeningPoint);
        // Add our application as a SIP listener.
        this.sipProvider.addSipListener(this);
        // Create the contact address used for all SIP messages.
        this.contactAddress = this.addressFactory.createAddress("sip:" + this.ip + ":" + this.port);
        // Create the contact header used for all SIP messages.
        this.contactHeader = this.headerFactory.createContactHeader(contactAddress);

        // Display the local IP address and port in the text area.
        this.textArea.append("Local address: " + this.ip + ":" + this.port + "\n");
    } catch (ParseException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (TooManyListenersException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (InvalidArgumentException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (ObjectInUseException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (PeerUnavailableException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    } catch (TransportNotSupportedException e) {
        // If an error occurs, display an error message box and exit.
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        System.exit(-1);
    }
}                       

private void onRegisterStateless(java.awt.event.ActionEvent evt) {                                     
    // A method called when you click on the "Reg (SL)" button.
    try {
        // Get the destination address from the text field.
        Address addressTo = this.addressFactory.createAddress(this.textField.getText());
        // Create the request URI for the SIP message.
        javax.sip.address.URI requestURI = addressTo.getURI();

        // Create the SIP message headers.
        // The "Via" headers.
        ArrayList viaHeaders = new ArrayList();
        ViaHeader viaHeader = this.headerFactory.createViaHeader(this.ip, this.port, "udp", null);
        viaHeaders.add(viaHeader);
        // The "Max-Forwards" header.
        MaxForwardsHeader maxForwardsHeader = this.headerFactory.createMaxForwardsHeader(70);
        // The "Call-Id" header.
        CallIdHeader callIdHeader = this.sipProvider.getNewCallId();
        // The "CSeq" header.
        // CSeqHeader cSeqHeader = this.headerFactory.createCSeqHeader(1L, "REGISTER");
        CSeqHeader cSeqHeader = this.headerFactory.createCSeqHeader(1L, Request.MESSAGE);

        // The "From" header.
        FromHeader fromHeader = this.headerFactory.createFromHeader(this.contactAddress, String.valueOf(this.tag));
        // The "To" header.
        ToHeader toHeader = this.headerFactory.createToHeader(addressTo, null);

        // Create the REGISTER request.
        Request request = this.messageFactory.createRequest(
                requestURI,
                "REGISTER",
                callIdHeader,
                cSeqHeader,
                fromHeader,
                toHeader,
                viaHeaders,
                maxForwardsHeader);
        // Add the "Contact" header to the request.
        request.addHeader(contactHeader);

        // Send the request statelessly through the SIP provider.
        this.sipProvider.sendRequest(request);

        // Display the message in the text area.
        this.textArea.append(
                "Request sent:\n" + request.toString() + "\n\n");
    } catch (ParseException e) {
        // If an error occurred, display the error.
        this.textArea.append("Request sent failed: " + e.getMessage() + "\n");
    } catch (InvalidArgumentException e) {
        // If an error occurred, display the error.
        this.textArea.append("Request sent failed: " + e.getMessage() + "\n");
    } catch (SipException ex) {
        JOptionPane.showMessageDialog(null, ex.getMessage());
    }
    // If an error occurred, display the error.

}     

这种对抗的原因是什么?我该如何解决?

0 个答案:

没有答案