javax.sip.SipException:发送请求

时间:2018-07-31 09:34:16

标签: java sip jain-sip

我想使用Jain sip api注册到sip服务器。但是,返回错误“ javax.sip.SipException: IOException occured while Sending Request”。

如果无法正确生成Sip消息,则说明网络无法访问:数据报发送失败。

输出我写为逻辑的代码中的REGISTER SIP消息似乎是正确的。我只是不确定端口。

该代码产生的注册凭证如下。 要求:注册sip:test.spoiler.com.tr:5060 SIP / 2.0 呼叫ID:3235ae8a968869c2525bf1035d05d168@192.168.56.1 CSeq:1个寄存器 来自:;标签= 2065198559 至: 通过:SIP / 2.0 / UDP 192.168.56.1:50600 // //我也尝试在此处写入Sip服务器的IP地址 最大前进:70 过期:5 内容长度:0

My sip server that I want to connect to is: test.spoiler.com.tr
AOR address-> sip: test.spoiler.com.tr: 5060
UAS address -> sip: 800@test.spoiler.com.tr: 5060

我还指出了UAS地址作为我想同时注册的Sip的用户。所以; toHeader-> fromHeader->;标签= 2065198559 我写了我的SIP服务器地址,以便Via连接到第一个SIP服务器。在正常情况下,它会在本地主机上获取IP。 尽管我尝试了本地主机IP,但结果没有改变。

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.ParseException;
import java.util.*;
import javax.sip.*;
import javax.sip.address.*;
import javax.sip.header.*;
import javax.sip.message.*; 
public class exampleListener implements SipListener {

SipFactory sipFactory;
SipStack sipStack;
ListeningPoint listeningPoint;
SipProvider sipProvider;
HeaderFactory headerFactory;
AddressFactory addressFactory;
MessageFactory messageFactory;
int tag = (new Random()).nextInt();
long LCseqDegeri = 1;
exampleGUI GUI;

public exampleListener(exampleGUI gui) {
    try {
        this.GUI = gui;

        sipFactory = SipFactory.getInstance();
        sipFactory.setPathName("gov.nist");

        Properties properties = new Properties();
        properties.setProperty("javax.sip.STACK_NAME", "sipStack");
        sipStack = sipFactory.createSipStack(properties);

        String sIP = InetAddress.getLocalHost().getHostAddress();
        int iPort = GUI.getPort();
        String protocol = "udp";
        listeningPoint = sipStack.createListeningPoint(sIP, iPort, protocol);

        sipProvider = sipStack.createSipProvider(listeningPoint);
        sipProvider.addSipListener(this);
        headerFactory = sipFactory.createHeaderFactory();
        addressFactory = sipFactory.createAddressFactory();
        messageFactory = sipFactory.createMessageFactory();

        GUI.setBATDAU("SIP Başlatıldı: " + sIP + ":" + iPort);

    } catch (UnknownHostException | TooManyListenersException | InvalidArgumentException | ObjectInUseException | PeerUnavailableException | TransportNotSupportedException ex) {
        System.out.println(ex.getMessage());
    }
}

public void sendMessage() throws UnknownHostException {
    try {

        Address desAddress = addressFactory.createAddress(GUI.getUAS());
        System.out.println("UAS destination Address: " + desAddress);
        Address AORAddress = addressFactory.createAddress(GUI.getAOR());
        System.out.println("AOR Address: " + AORAddress);
        ToHeader toHeader = headerFactory.createToHeader(desAddress, null);
        System.out.println("toHeader: " + toHeader);
        FromHeader fromHeader = headerFactory.createFromHeader(desAddress, String.valueOf(tag));
        System.out.println("fromHeader: " + fromHeader);
        String sIP = InetAddress.getLocalHost().getHostAddress();//GUI.getSipServer();
        System.out.println("Via ilk sip sunucusuna bağlanır. SIP Sunucusu: " + sIP);
        ViaHeader viaHeader = headerFactory.createViaHeader(sIP, GUI.getPort(), "udp", null);
        ArrayList viaHeaders = new ArrayList();
        viaHeaders.add(viaHeader);
        System.out.println("viaHeader:" + viaHeader);
        MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(70);
        System.out.println("maxForwardsHeader: " + maxForwardsHeader);
        CallIdHeader callIdHeader = sipProvider.getNewCallId();
        System.out.println("callIdHeader: " + callIdHeader);
        CSeqHeader cSeqHeader;
        cSeqHeader = headerFactory.createCSeqHeader(LCseqDegeri, Request.REGISTER);
        System.out.println("cSeqHeader: " + cSeqHeader);
        ExpiresHeader expiresHeader = headerFactory.createExpiresHeader(5);
        URI requestURI = AORAddress.getURI();
        Request request = messageFactory.createRequest(requestURI, "REGISTER",
                callIdHeader, cSeqHeader, fromHeader, toHeader, viaHeaders, maxForwardsHeader);
        request.addHeader(expiresHeader); 
        System.out.println("----------------------------------------------------");
        System.out.println("request: " + request);

        sipProvider.sendRequest(request);


        GUI.displayMessage("Talep : " + request.toString());
    } catch (ParseException | InvalidArgumentException | SipException ex) {
        for (StackTraceElement ste : ex.getStackTrace()) {
            System.out.println(ste);
        }
        System.out.println(ex);
    }
}
  

该错误的详细说明

gov.nist.javax.sip.SipProviderImpl.sendRequest(SipProviderImpl.java:741)
exampleBasic.exampleListener.sendMessage(exampleListener.java:90)
exampleBasic.exampleGUI.cmdGOIActionPerformed(exampleGUI.java:199)
exampleBasic.exampleGUI.access$200(exampleGUI.java:16)
exampleBasic.exampleGUI$3.actionPerformed(exampleGUI.java:115)
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
java.awt.Component.processMouseEvent(Component.java:6533)
javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
java.awt.Component.processEvent(Component.java:6298)
java.awt.Container.processEvent(Container.java:2238)
java.awt.Component.dispatchEventImpl(Component.java:4889)
java.awt.Container.dispatchEventImpl(Container.java:2296)
java.awt.Component.dispatchEvent(Component.java:4711)
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4897)
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4534)
java.awt.LightweightDispatcher.dispatchEvent(Container.java:4475)
java.awt.Container.dispatchEventImpl(Container.java:2282)
java.awt.Window.dispatchEventImpl(Window.java:2746)
java.awt.Component.dispatchEvent(Component.java:4711)
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
java.awt.EventQueue.access$500(EventQueue.java:97)
java.awt.EventQueue$3.run(EventQueue.java:709)
java.awt.EventQueue$3.run(EventQueue.java:703)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
java.awt.EventQueue$4.run(EventQueue.java:733)
java.awt.EventQueue$4.run(EventQueue.java:731)
java.security.AccessController.doPrivileged(Native Method)
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
javax.sip.SipException: IO Exception occured while Sending Request

我的图书馆:
-javax.sip-> jain-sip-api 1.2.1
-javax.sip-> in那教里1.2.244 -org.mobicents.slee.media-> media-rtp 1.0
-javax.media jmf 2.1.1e -org.zenframework.z8.dependencies.commons log4j-1.2.17 2.0

如何获取IO错误。我该如何解决?通过互联网查看时,找不到该错误的解决方案。

0 个答案:

没有答案