×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    55

    Angry Http Connection Using Nokia 9500

    Hi! I'm newbie here. Currently, I'm developing an applcation which involve the http connection. I need to stream images continuously from the server and my application will 'hang' after some time. I have tried many types of way to solve this issue but still unable to solve it. There's no http response back from the server if the AP signal strength is poor. I have used the setRequestProperty but it still unable to help me. Here are some of my code :

    connection = (HttpConnection)Connector.open(myurl);
    connection.setRequestProperty( "User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1" );
    connection.setRequestProperty("Cache-Control", "no-cache");
    connection.setRequestProperty("Connection", "close");

    int code = connection.getResponseCode();

    if (code != HttpConnection.HTTP_OK)
    {
    }
    else
    {
    byte img[];
    int mylength = (int) connection.getLength();
    if (mylength != -1)
    {
    img = new byte[length];
    istream.readFully(img);
    }

    else
    {
    bstream = new ByteArrayOutputStream();
    int chr;
    while ((chr = istream.read()) != -1)
    bstream.write(chr);
    img = bstream.toByteArray();
    bstream.close();
    }

    Is it something to do with the setRequestProperty method which caused no response back from the server? Is it 'connection.setRequestProperty("Connection", "close"); ' will close the http connection?


    Please help!


    Thanks!


    Jac

  2. #2
    Regular Contributor
    Join Date
    Jul 2005
    Posts
    79

    Re: Http Connection Using Nokia 9500

    You should make this HttpRequest to the server in a different thread - because network connection holds device resources during connection.
    And your application may hang.

    - amin

  3. #3
    Regular Contributor
    Join Date
    Nov 2005
    Posts
    67

    Re: Http Connection Using Nokia 9500

    Check always after
    connection = (HttpConnection)Connector.open(myurl);

    /// New row on your source

    if ( connection == null )
    {
    throw ....
    }

Similar Threads

  1. HTTP Connection on Nokia 3220b has Problems.
    By agyepong in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-12-29, 03:57
  2. HTTP Connection on Nokia 7650
    By patelvk in forum Mobile Java General
    Replies: 0
    Last Post: 2003-04-29, 04: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
  •