javax.sip.SipException: IO Exception occured while Sending Request

737 Views Asked by At

I want to register to the sip server using Jain sip api. However, the error "javax.sip.SipException: IOException occured while Sending Request" is returned.

If I can not generate the sip message correctly, network is unreachable: datagram send failed.

It seems correct that the REGISTER SIP message in the code I wrote as logic is output. I just can not be sure of the ports.

The REGISTRANT TICKET produced by the code is as follows. request: REGISTER sip: test.spoiler.com.tr: 5060 SIP / 2.0 Call-ID: [email protected] CSeq: 1 REGISTER From: ; tag = 2065198559 To: Via: SIP / 2.0 / UDP 192.168.56.1:50600 // I also tried to write the IP address of the Sip server here Max-Forwards: 70 Expires: 5 Content-Length: 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: [email protected]: 5060

I also pointed to the UAS address as the user of the Sip I want to register at the same time. So; toHeader-> fromHeader-> ; tag = 2065198559   I wrote my sip server address so that Via connects to the first sip server. In normal cases it gets the IP on the local host. Although I tried Local Host IP, the result does not change.

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);
    }
}

Detailed description of the error

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

My libraries:
- javax.sip -> jain-sip-api 1.2.1
- javax.sip -> jain-sip-ri 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

How do I get the IO error. How can I resolve it? When I looked through the internet, I did not find the solution of this error.

0

There are 0 best solutions below