×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    2

    SIP port configuration on emulator

    Hi,

    i am working on a j2me-jsr180 sip client. Currently working on emulator.

    i try to send a request from 5062 port of my PC.
    However, my request goes out from a random port of my PC like :1947.
    This port changes each time i run the program.

    I do not handle the response of the request beacuse i do not know which port do i send? which port i must listen?

    Is there anybody got idea?

    Thanks..

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    2

    Re: SIP port configuration on emulator

    Hi,
    Here is the code:

    Would anybody have opportunity to test the code, would tell me where the problem is?

    i repeat the problem:
    i cannot send the message from 5062 port which i wanna do?
    it goes out from any other port avaible? n so i cannot handle the response

    plz help..

    /***register code***/

    import java.io.*;

    import javax.microedition.io.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.sip.*;

    public class register extends MIDlet implements CommandListener, SipClientConnectionListener, SipServerConnectionListener{
    private Form form;
    private Display display;
    private Command exit, m_reg, m_im;
    public SipClientConnection scc = null;
    public SipConnectionNotifier scn = null;

    public register() {
    display = Display.getDisplay(this);
    exit = new Command("Exit", Command.EXIT, 1);
    m_reg= new Command("Register",Command.ITEM,1);
    m_im= new Command("Send IM",Command.ITEM,2);
    form = new Form("GUI");
    form.addCommand(exit);
    form.addCommand(m_reg);
    form.addCommand(m_im);
    form.setCommandListener(this);
    }

    protected void startApp() throws MIDletStateChangeException{
    display.setCurrent(form);
    try{
    scn = (SipConnectionNotifier) Connector.open("sip:5062");
    scn.setListener(this);
    scc = (SipClientConnection) Connector.open("sip:user1@SERVERIPADDR:5065");
    scc.setListener(this);
    System.out.println("Connections Established");
    }
    catch(Exception e){}
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean unconditional){
    try{
    scc.close();
    System.out.println("Connections Closed");
    }
    catch(Exception e){}
    }

    public void doRegister(final String username, final String password, final String realm) {
    String contact = null;


    try {
    // contact = new String("sip:user1@"+scn.getLocalAddress()+":"+scn.getLocalPort());
    contact = new String("sip:user1@"+scn.getLocalAddress()+":"+"5062");
    scc.initRequest("REGISTER", scn);
    scc.setHeader("From", "sip:user1@DOMAIN.com");
    scc.setHeader("To", "sip:user1@DOMAIN.com");
    scc.setHeader("Contact", contact);
    scc.send();
    }
    catch(Exception ex)
    {
    // handle Exceptions
    }
    // new Thread(){
    // public void run(){
    boolean handled = false;
    int scode = 0;

    while(!handled) {
    SipHeader sh;
    // wait max 3 secs for response
    try {
    scc.receive(5000);
    } catch (SipException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    scode = scc.getStatusCode();
    System.out.println( "Received Response: " + scode );
    switch(scode)
    {
    case 401:
    sh = new SipHeader("WWW-Authenticate",
    scc.getHeader("WWW-Authenticate"));
    // realm = sh.getParameter("realm");
    // here for example, prompt user for password for this realm
    // set credentials to initiate re-REGISTER
    try {
    scc.setCredentials(username, password, realm);
    } catch (SipException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    break;

    case 407:
    sh = new SipHeader("Proxy-Authenticate",
    scc.getHeader("Proxy-Authenticate"));
    // realm = sh.getParameter("realm");
    // here for example, prompt user for password for this realm
    // set credentials to initiate re-REGISTER
    try {
    scc.setCredentials(username, password, realm);
    } catch (SipException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    break;

    case 200:
    // handle OK response
    handled = true;
    break;
    default:
    // handle other responses
    handled = true;
    }
    }
    // }
    // }.start();
    System.out.println("End of doRegister");
    }

    private void sendMessage() {
    try {
    //sc = (SipClientConnection) Connector.open(address.getString());
    //sc.setListener(this);
    String text = "Message Content";
    scc.initRequest("MESSAGE", null);
    scc.setHeader("From", "sip:user1@DOMAIN.com");
    // scc.setHeader("To", "sip:user2@DOMAIN.com");
    scc.setHeader("Subject", "konu");
    scc.setHeader("Content-Type", "text/plain");
    scc.setHeader("Content-Length", ""+text.length());
    OutputStream os = scc.openContentOutputStream();
    os.write(text.getBytes());
    os.close(); // close and send out
    //startTime = System.currentTimeMillis();
    }
    catch(Exception ex) {
    ex.printStackTrace();
    }
    }

    public void commandAction(Command command, Displayable displayable) {
    if (command == exit) {
    destroyApp(false);
    notifyDestroyed();
    }
    else if(command == m_reg){
    doRegister("user1","1234","realm");
    }
    else if(command == m_im){
    Thread t = new Thread() {
    public void run() {
    sendMessage();
    }
    };
    t.start();
    }
    }

    public void notifyResponse(SipClientConnection scc) {
    System.out.println("notifyResponse");
    }

    public void notifyRequest(SipConnectionNotifier scc) {
    System.out.println("notifyRequest");
    }
    }

  3. #3
    Registered User
    Join Date
    Sep 2007
    Posts
    5

    Re: SIP port configuration on emulator

    Hi,


    I am having the same problem like yours ( sip messages are sent on different UDP port each time instead of 5060 that I configured in SipConnectionNotifier) and I am wondering if you know the solution to the problem. I appreciate your help.

    I was working on a code base for some time,I did not see this problem then but I left that code base for couple weeks and now when I try I get it run again this strange issue like yours. May be I changed some thing unknowingly during this time.

    Thanks
    Venkat

  4. #4
    Registered User
    Join Date
    Oct 2007
    Location
    Noida
    Posts
    152

    Lightbulb Re: SIP port configuration on emulator

    hi vkunapuli,
    Well i am also trying to figure out the same thing. have found out the following facts about the prblem:

    1.>You have to open the SIP connection in the shared mode.So that the port is controlled by the system and not the application

    scn = (SipConnectionNotifier)Connector.open"sip:*;type=\"application/vnd\"");

    2.>ctaddr = new String("sip:100@"+scn.getLocalAddress()+":"+scn.getLocalPort());

    this will give a random port and you system's ipadress. but even then the problem is there.
    After checking the same from the network monitor i found out that the port of the system receving the data and the port inthe Contact header is dfferent and that is why it is not leting the peer register .

    i am on it and will let you know if i get some update . please have alook and let me know if u get some solution for the same.

Similar Threads

  1. Problems running SIP application on S60 emulator
    By ajaybrar in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2006-03-08, 06:32
  2. Problem with SIP Plug-in for Series 60 SDK 2.0
    By jalakuri in forum Symbian Tools & SDKs
    Replies: 27
    Last Post: 2005-08-22, 09:55
  3. 9500 emulator configuration problems
    By Cinghius in forum General Development Questions
    Replies: 0
    Last Post: 2005-05-02, 16:34
  4. virtual serial port driver VSPD doesn't work with emulator
    By smallfish_ntu in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2003-05-24, 16:21
  5. EAIF Emulator doesn't works properly in my case
    By savitaamin in forum General Messaging
    Replies: 1
    Last Post: 2002-08-14, 12:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×