×

Discussion Board

Page 1 of 3 123 LastLast
Results 1 to 15 of 33
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    SocketConnection - works only in the emulator :-(

    Hello everybody,

    I try to connect to a remote server using tcp ip
    and a non stardard port 1xxx.

    And I'm not far away from getting mad about this :-(

    Can anybody tell me what's wrong with my code?

    It works great in the S40 emulator but hangs on the 6230i.
    I have GPRS connectivity enabled on the phone ...

    AFAIK I don't need a certificate for ip connection on ports like 1273 - or am I wrong here?


    Thank you VERY much!
    Peter


    SocketConnection conn= null;

    InputStream is = null;
    OutputStream os = null;
    StringBuffer sb = new StringBuffer();

    int rc = 0;
    try
    {
    conn = (SocketConnection) Connector.open("socket://"+url);
    is = conn.openInputStream();
    os = conn.openOutputStream();

    String wrappedLogin = "someData";
    String wrappedData = "even more data";

    os.write(wrappedLogin.getBytes());
    os.write(wrappedData.getBytes());

    int index= 0;
    int ch;
    while ((ch = is.read()) != -1)
    {
    index++;
    if ((ch != 0x0a) && (ch != 0x00) && (index>7))
    {
    sb.append((char) ch);
    }
    }
    }
    catch (IOException ex)
    {
    return ex.getMessage();
    }
    finally
    {
    if (is!=null)
    {
    try
    {
    is.close();
    }
    catch (IOException ex)
    {
    }
    }

    if (os!=null)
    {
    try
    {
    os.close();
    }
    catch (IOException ex)
    {
    }
    }

    if (conn!=null)
    {
    try
    {
    conn.close();
    }
    catch (IOException ex)
    {
    }
    }
    }

  2. #2
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: SocketConnection - works only in the emulator :-(

    "It works great in the S40 emulator but hangs on the 6230i."

    So no "access denied" (or something along those lines, i.e. security exception) is displayed? if it just hangs, i do not think signing would be a solution.

    It might be that the your operator does not allow access through that port.

    Hartti

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105
    What do you mean with hang. Perhaps you have a threading problem.

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    Re: SocketConnection - works only in the emulator :-(

    Thank you both for your feedback!

    What happens on the phone:
    When I start the function in my app (on the phone) the phone is asks me whether it is ok to use air time (I agree of course ...). After that I get an java.io.IOException - Error occured whilst opening connection.

    The mobile phone can open a gprs connection (gprs always on...)
    I can load webpages in the browser.

    So may be the port is blocked ... the provider hotline told me to use 9201 (*)

    any idea what is a open port for t-mobile or vodafone?

    (*) but I'm not sure it they really understand what I was trying to do ...

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    Re: SocketConnection - works only in the emulator :-(

    I have to correct myself ... the mobile opens a gprs connection shown by the [G] in the uper left corner and after a long delay I get a
    java.io.InterruptedIOExecption.

    I tried 1234, 1273 and 9201 for ports and I currently use a t-mobile card

    Any ideas?

    Thank you!
    Peter

  6. #6
    Nokia Developer Champion
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192

    Re: SocketConnection - works only in the emulator :-(

    Have you been able to use network from any other Java application? It might be that you have not correctly defined the access point for midlets

    Hartti

  7. #7
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105
    There are a lot of T-Mobile networks around each with a different setting. Which country do you live in? Additionally, do you get just a G or a [G]? In the latter case, either you connect with the wrong access point (WAP instead of Internet) or your have misspelled the sever's name. In the first case, you have not defined a default access point at all.

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    Re: SocketConnection - works only in the emulator :-(

    Quote Originally Posted by hartti
    Have you been able to use network from any other Java application? It might be that you have not correctly defined the access point for midlets
    Hartti

    I have no other java apps to test network traffic. Can you suggest one that must work on a 6230i?

    Thank you!
    Peter

  9. #9
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    Re: SocketConnection - works only in the emulator :-(

    Quote Originally Posted by traud
    Which country do you live in?
    Germany.

    Quote Originally Posted by traud
    Additionally, do you get just a G or a [G]? In the latter case, either you connect with the wrong access point (WAP instead of Internet) or your have misspelled the sever's name.
    [G] The server name is correct (and the server is running ...)

    Now I must admit that I'm a newbie to Nokia phones :-(
    How can I check which access point the phone is using?

    Thank you!
    Peter

  10. #10
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105
    Change the language to English first:
    Nokia > Menu > Settings > Phone > Language > English.

    Nokia > Menu > Settings > Configuration > Preferred access point > T-Mobile > Options > Details > GPRS access point > internet.t-mobile

    You can add your own account, when this default one is wrong:
    Nokia > Menu > Settings > Configuration > Personal > Add or Options > Add new > Access Point > internet.t-mobile

  11. #11
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: SocketConnection - works only in the emulator :-(

    i had tried the same thing using the sockets like you are doing right now.

    i was also on the brink of madness that everything was working fine on emulator but not on cellphone. the only logival explanation i have about this issue is that your mobile does not allow you to open a socket connection because of some securtiy issue. this security issue has been put in by the mobile phone manufacturer. this was the response i got when i posted my question to (java)sun people. your code is 100 percent correct wheather it works on your cellphone or not is a different situation all together.
    but i am sure of few things. it has nothing to do with your not signing your midlet or checking your configuration or anything.

    hope this will help. i hate to see another man getting mad as i was. lol

    regards
    Nouman

  12. #12
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    Re: SocketConnection - works only in the emulator :-(

    You can add your own account, when this default one is wrong:
    Nokia > Menu > Settings > Configuration > Personal > Add or Options > Add new > Access Point > internet.t-mobile
    Nokia > Menu > Settings > Configuration
    ... got that

    Personal
    I take Personal (configuration settings)

    Add or Options > Add new > Access Point
    yes ...

    now I have to choose from ...
    Account name (set to Access point)
    and
    Access point settings

    ... I take Access point settings ...

    now I have
    Data bearer (set to GPRS)
    and
    Bearer setting

    ... I take Bearer settings ...

    now I have
    GPRS access point (set to internet)
    and
    Autentification type (set to normal)
    and
    User name (empty)
    and
    password (empty)

    I'll change GPRS access point to internet.t-mobile

    Right?


    ... but it doesn't change the behaviour :-(

    Thank you!
    Peter

  13. #13
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105
    I forgot, you have to select this new setting then, too:
    Nokia > Menu > Settings > Configuration > Preferred access point > T-Mobile New

    Yes, I shortened a bit because the Nokia created menu names are terrible (long and useless). Do not think their usability experts revised the naming down there.
    Quote Originally Posted by nicenouman
    this security issue has been put in by the mobile phone manufacturer.
    T-Mobile Germany has no such practise. No other German operator has that at the moment. I think, I would be aware of something like that…

  14. #14
    Registered User
    Join Date
    Sep 2006
    Posts
    21

    Re: SocketConnection - works only in the emulator :-(

    Quote Originally Posted by traud
    I forgot, you have to select this new setting then, too:
    Nokia > Menu > Settings > Configuration > Preferred access point > T-Mobile New
    it still doesn't work :-(

    Any idea? It seems to be harder (at least for me) to configure the phone than to write the software ....


    Thank you,
    Peter

  15. #15
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,105
    Is there still a G, then a [G] and then a longer pause while the [G] is shown? Connect your computer via the Nokia and check your DNS is available within T-Mobile's network.

Similar Threads

  1. Emulator screen gone... Help needed
    By meihuadao in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2006-03-22, 13:30
  2. Replies: 2
    Last Post: 2006-03-17, 06:40
  3. Socket connection hangs on 9500 but works well in the WTK 2.2 emulator
    By falconpl in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-07-30, 21:38
  4. EAIF Emulator doesn't works properly in my case
    By savitaamin in forum General Messaging
    Replies: 1
    Last Post: 2002-08-14, 12:07
  5. Works in Emulator, not in REAL 7650.
    By mctenny in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2002-08-12, 02:48

Posting Permissions

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