×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Mar 2003
    Location
    Hong Kong
    Posts
    8

    HttpConnection hangs in repeated requests

    Hi,

    I have a MIDlet that makes a HTTP GET request every 10 sec. I find that it hangs once for a while in the openInputStream() call and its frequency seems to depend on the surronding environment (e.g. indoor, outdoor). I'm using the Nokia 7650 and the WAP 9.6k connection. Does anyone come across the same problem. Any idea why?

    Thanks


    (Source codes attached below)


    private StringBuffer content=new StringBuffer(128);

    public void run()
    {
    while (true)
    {
    HttpConnection conn=null;
    InputStream in=null;

    content.setLength(0);

    try
    {
    conn=(HttpConnection)Connector.open(url, Connector.READ, true);
    in=conn.openInputStream();

    int n;
    while ((n=in.read()) != -1)
    content.append((char)n);
    }
    catch (Exception e) {}

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

    try
    {
    Thread.sleep(10000);
    }
    catch(InterruptedException e) {}
    }
    }

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    Bordeaux, France
    Posts
    7
    We have exactly the same problem on 7650 with V4.39 firmware.
    Doing frequent http connections makes the java application to exit badly !

    Is there any workarounds ?

    Jean-Dominique
    BeTomorrow

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Same problem on 7650 v3.16.
    Only on the phone. No problems on the emulator.
    Would love to hear a solution....

    shmoove

    [edit]
    Just thought I might add that the server side is implemented with ASP pages on an IIS 5.0 server. Maybe there's a connection there...
    [/edit]
    Last edited by shmoove; 2003-04-01 at 08:45.

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    CM_WONG said his app hangs on openInputStream(), but as far as I can tell mine hangs on getResponseCode(). I call getResponeCode() before I open the input stream though, so for both of us it happens when the connection transitions into the connected state.
    What I'm saying is that I don't think it has anything to do specifically with either openInputStream() or getResponseCode(), but with the transition to the connected state itself which can be caused by these two or a bunch of other functions (I bet that if someone tries to call getLength or getType() as the next call after opening the connection it will hang on those).

  5. #5
    Registered User
    Join Date
    Mar 2003
    Location
    Copenhagen, Denmark
    Posts
    18
    Hi there.

    Maybe it has something to do with a full heap - due to object creation when opening new connections rapidly?

    Just a suggestion.

  6. #6
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Once every three seconds is not THAT often. I also have a call to System.gc() before making the connections, so I don't think that is the case....

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    2
    I have the same problem. The phone hangs (only reboot helps, no menu key or red key) when trying to call outputStream.close().

    Nokia - or anyone who knows, any comments would be appreciated. Is this a known bug? What's the cause for this bug?

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    43
    Did anyone ever get an answer on this? I too am having problems on a 3650. My HttpConnection works fine for some number of requests/responses, but then it starts throwing IOExceptions with status = -33 or -20019. Is ther any way around this?

Posting Permissions

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