×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jun 2003
    Location
    Irvine, CA
    Posts
    11

    Connection times out after 10 requests...

    Here's my problem: In this simple test MIDlet I do a GET followed by about 20 POSTs and a final GET to a CGI on a webserver. The strange thing is that after about 10 or 11 requests go through running on the Nokia 3650 (phone not emulator) I get an IOException with "status -33" which I have learned means timeout. After getting the first IOException all subsequent requests also timeout. It's as if my net connection is suddenly dead. And it consistently happens after about 10 messages.

    So my question is this: am I forgetting to clean up some resource or something and causing the networking layer of the phone to stop? I make sure to close the HTTPConnection and all my streams when I am done with them...

    Here's my source code (very simple with URLs changed to protect the innocent):


    public class tTestForm extends Form implements CommandListener
    {
    private Command fConnectCommand;

    public tTestForm()
    {
    super("Test");
    setCommandListener(this);

    fConnectCommand = new Command("Connect", Command.SCREEN, 1);
    addCommand(fConnectCommand);
    }


    public void commandAction(Command command, Displayable displayable)
    {
    if (command == fConnectCommand)
    {
    mGet("http://www.myserver.com/mycgi.cgi?param=login");
    for (int i = 0; i < 20; i++)
    {
    mPost("http://www.myserver.com/mycgi.cgi", "mydata");
    }
    mGet("http://www.myserver.com/mycgi.cgi?param=logout");
    }


    public String mGet(String url)
    {
    try
    {
    HttpConnection connection = (HttpConnection)Connector.open(url,
    Connector.READ_WRITE);

    if (connection.getResponseCode() == HttpConnection.HTTP_OK)
    {
    StringBuffer response = new StringBuffer();

    // obtain a DataInputStream from the HttpConnection
    DataInputStream dis = new DataInputStream(connection.openInputStream());

    // retrieve the response from the server
    int ch;
    while ((ch = dis.read()) != -1)
    {
    response.append((char)ch);
    }

    dis.close();
    connection.close();
    connection = null;

    return response.toString();
    }
    else
    {
    connection.close();
    connection = null;
    }
    }
    catch (IOException E)
    {
    append(E.getMessage());
    E.printStackTrace();
    }

    return null;
    }


    public String mPost(String url, String data)
    {
    try
    {
    HttpConnection connection = (HttpConnection)Connector.open(url,
    Connector.READ_WRITE);

    // set the request method to POST
    connection.setRequestMethod(HttpConnection.POST);

    // obtain DataOutputStream for sending the request string
    DataOutputStream dos = connection.openDataOutputStream();
    byte[] requestBody = data.getBytes();

    // send request string to server
    for (int i = 0; i < requestBody.length; i++)
    {
    dos.writeByte(requestBody[i]);
    }

    dos.close();

    // Connection is made with a call to getResponseCode()
    //
    if (connection.getResponseCode() == HttpConnection.HTTP_OK)
    {
    StringBuffer response = new StringBuffer();

    // obtain a DataInputStream from the HttpConnection
    DataInputStream dis = new DataInputStream(connection.openInputStream());

    // retrieve the response from the server
    int ch;
    while ((ch = dis.read()) != -1)
    {
    response.append((char)ch);
    }

    dis.close();
    dis = null;

    connection.close();
    connection = null;

    return response.toString();
    }
    else
    {
    connection.close();
    connection = null;
    }
    }
    catch (IOException E)
    {
    append(E.getMessage());
    E.printStackTrace();
    }

    return null;
    }
    }


    Thanks in advance.

    -Mike Hershberg-
    -Software Engineer-
    -Quicksilver Software, Inc.-

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    10
    Hmm.. I'm getting the same symptoms as you are ... a series of requests on the 3650, and then "Status = -33" .. and any subsequent connections just won't work.

    After about 10+ requests, too... other than closing all streams (which I did), I can't think of what could be the problem. Did you figure out anything on your end?

  3. #3
    Registered User
    Join Date
    Jun 2003
    Location
    Irvine, CA
    Posts
    11
    Wow, this was a while ago and since then we've had to tackle a number of network-related issues. But I think I remember what we did to solve this one.

    Turns out the problem was with the Access Point's gateway on the 3650. The default Access Point (for AT&T Wireless in our case) used to connect was the culprit. For some unexplained reason it caused us to fail after 10 or so HTTP requests. When we created a new Access Point on the phone (Tools->Settings->Connection->Acces Points) with a Gateway IP Address of 0.0.0.0 and used it to connect instead of the default Access Point we no longer saw the 10 request bug.

    Here are our Access Point settings:

    Connection name: any name
    Data bearer: GPRS
    Access point name: Proxy
    User name: None
    Prompt password: No
    Password:
    Authentication: Normal
    Gateway IP address: 0.0.0.0

    Hope this helps!

    -Mike-

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    10
    Hi Mike,

    Thanks for replying .. I know I was taking a chance in trying to revive such an old thread.

    Anyway, I heard about the Gateway 0.0.0.0 solution, but it doesn't seem to work for us (operator in Malaysia). For some reason, the internet APN (that uses 0.0.0.0) just keeps returning "<h1>Bad Request</h1>" .. and using the WAP APN and changing the Gateway to 0.0.0.0 really disables any connectivity.

    Basically, we're stuck over here as to what to do. Anyone following this and experiencing similar problems should check out http://discussion.forum.nokia.com/fo...=&postid=84067

    In any case, though, glad your problem worked out, Mike, and thanks for the response again!

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    14

    Re: Connection times out after 10 requests...

    Is there a way to determine the timeout?

Posting Permissions

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