Develop an application in java-jain-sip language that uses the sip protocol to make a call

Hello to you, I hope you are well,
I am developing an application which to make a call using the SIP protocol using the jain-sip-api-1.2 library and the jain-sip-ri1.2 library.

I have implemented my stack (the stack) on my local ip address (localhost),using the path name gov.nist

after having created the sip uri address, of my own pc as well as the sipuri of the sipserver entity that I must contact.

and when I create a new client transaction and run the program for the register request, it shows me this error.

you will find attached my code for the implementation of the daughter and the creation of the register request


Exception in thread “main” javax.sip.SipException: IO Error sending request
at gov.nist.javax.sip.stack.SIPClientTransaction.sendRequest(SIPClientTransaction.java:985)
at softphoneSIP.UAC.register(UAC.java:218)
at softphoneSIP.es.main(es.java:19)
Caused by: java.net.SocketException: Network is unreachable: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)


	public  UAC(int Port,String transport,String ippile) throws TransportNotSupportedException, InvalidArgumentException, ObjectInUseException, TooManyListenersException, PeerUnavailableException {
	cSeq=1;
	//dataport pour la reception des flux de données 
	
	sipfactory=SipFactory.getInstance();
	sipfactory.setPathName("gov.nist");
	
	//creation des fabrique 
	headerfactory=sipfactory.createHeaderFactory();
	addressFactory=sipfactory.createAddressFactory();
	messageFactory=sipfactory.createMessageFactory();
	
	Properties stackprop=new Properties();
	//nom de la pile
	stackprop.setProperty("javax.sip.STACK_NAME", "UserAgentClient");
	stackprop.setProperty("javax.sip.IP_ADDRESS", ippile);
	stackprop.setProperty("javax.sip.RETRANSMISSION_FILTER", "true");
	stackprop.setProperty("gov.nist.javax.sip.TRACE_LEVEL", "16");
	
	//creation de la pile Sip
	sipstack=sipfactory.createSipStack(stackprop);
	
	listenningpoint=sipstack.createListeningPoint(sipstack.getIPAddress(), Port,transport);
	sipprovider=sipstack.createSipProvider(listenningpoint);
	sipprovider.addSipListener(this);
	
}

public void register() throws ParseException, InvalidArgumentException, SipException {
	
	 Address adrproxy;
	 Address adrlogique;
	 Address adrphysique;
	 String nomdomaine=null;
	 String nomuser=null;		

	 
	//la c'est le nom utilisateur
			String nomusersystem=System.getProperty("user.name");
			
			

			
			//creation de l'adresse du proxy ou l'entite sip  sur la quelle on veut envoyé de message 
			
			adrproxy=addressFactory.createAddress("sip"+"94015@192.198.230.172:5060");
			javax.sip.address.URI requestURI = adrproxy.getURI();
			System.out.println("debuug9H  "+""+requestURI);

					
			
			
			String uriphy=listenningpoint.getIPAddress()+""+listenningpoint.getPort();
			
			
			//creation de SIPuri
			SipURI sipuri= addressFactory.createSipURI(nomusersystem, uriphy);
			System.out.println("debuug "+""+sipuri);
			
			adrphysique = addressFactory.createAddress(nomusersystem, sipuri);
			
			System.out.println("debuug   "+" "+adrphysique);
			//construire l'entete SIPFrom 
			
			//nom du domaine du proxy ou l'entite que on veut contatcer
			nomdomaine="94015@192.198.230.172:5060";
			
			SipURI urilogique = addressFactory.createSipURI(nomuser, nomdomaine);
			
			adrlogique=addressFactory.createAddress("TestTahar2", urilogique);


			
			
			//creation du champs d'en-tete CallId
			CallIdHeader callidheader=sipprovider.getNewCallId();
			

					
			//creation Cseq n° de sequence  de transaction au sein d'une session ou dialogue
			CSeqHeader cseqHeader= headerfactory.createCSeqHeader(cSeq++,Request.REGISTER);
		

			
			//creation du champs MaxForward le nombre amximum de sauts
			MaxForwardsHeader maxforward=headerfactory.createMaxForwardsHeader(70);

			

			
			//creation de l'entet from et contacts ici math.random represente le tag du champs from ??
			FromHeader fromHeader= headerfactory.createFromHeader(adrphysique, ""+new Random().nextInt());
					
			

			ContactHeader contactheader=headerfactory.createContactHeader(adrphysique);
			int expires=6000;
			contactheader.setExpires(expires);
			
					
			//creation de l'entete to
			ToHeader toheader=headerfactory.createToHeader(adrlogique, null);
			System.out.println("debuug "+""+toheader);

			
			//creation de l'entéte via ici on peut fixe le type de transport a udp/tls/smtp
			ArrayList<ViaHeader> via=new ArrayList<ViaHeader>();
			ViaHeader viaheader= headerfactory.createViaHeader(listenningpoint.getIPAddress(), listenningpoint.getPort(), listenningpoint.getTransport(), null);
			via.add(viaheader);
			
			
			//creation du message grace a request
					
			//creation content type ici normalment sa sera en texte???
			contenttypeheader=headerfactory.createContentTypeHeader("text", "txt");
			
			System.out.println("debuug2 "+""+contactheader.getName());
			
			
			//adproxy @ de  l'entite ou on veut adresse le message
			Request register= messageFactory.createRequest(adrlogique.getURI(), Request.REGISTER, callidheader, cseqHeader, fromHeader, toheader, via, maxforward, contenttypeheader, contactheader);
			//Request register= messageFactory.createRequest(requestURI, Request.REGISTER, callidheader, cseqHeader, fromHeader, toheader, via, maxforward, contenttypeheader, contactheader);
			
			System.out.println(""+adrlogique.getURI());
			
			//this.sipprovider.sendRequest(register);
			
			
			//register.addHeader(allowheader);
					
			//Creation de la transaction "la requette register est base sur le type transaction pas dialogue " on peut les ajouetr une nouvelle declaration en cas ou des erreurs
			clienttransaction=sipprovider.getNewClientTransaction(register);
					 
			//envoi du message 
					 
			clienttransaction.sendRequest();
			

	
}

thank you in advance for your help, and logged so that I can correct this errors and register on the sipserver.

Asterisk is your “sipserver” ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.