×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    5

    Question Symbian V2 HTTP connection problem with WAP+Proxy

    Hello,

    I have a problem to connect with my application to a server behind a WAP APN Proxy with two Symbian V2 OS devices, specifically Nokia 7610 and Nokia 6600.

    The problem does not occur on Symbian V3 OS devices such as Nokia N95.

    My application is a J2ME application. When The application tries to establish a connection it fails with an HTTP Exception:

    Symbian OS Error=-36:General:System error

    Is there anyone who encountered this problem before and resolve this issue?
    Thank you!

    Best regards,
    Kobi Toueg

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Symbian V2 HTTP connection problem with WAP+Proxy

    -36, I am told, means "disconnected".

    Do you have other connected Java apps on the device? If not, try installing Opera Mini. If this has the same problem, then it is your connection settings you need to play with. If it works, then post the code that fails, and maybe we can see what's going on.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    5

    Re: Symbian V2 HTTP connection problem with WAP+Proxy

    Hi,

    I installed Opera and managed to surf through WAP APN.
    Here is the code I am using to establish the connection:

    Code:
    private void readContents(String request)
        {
            StringBuffer b = new StringBuffer();
            attempt++;
            b.append("attempt " + attempt + " content of " + request + " " + url + "\n");
            HttpConnection c = null;
            OutputStream os = null;
            InputStream is = null;
            TextBox t = null;
            try
            {
                long len = -1L;
                int ch = 0;
                long count = 0L;
                DEBUG(request + " Page: " + url);
                c = (HttpConnection)Connector.open(url);
                DEBUG("c= " + c);
                c.setRequestMethod(request);
               c.setRequestProperty("foldedField", "first line\r\n second line\r\n third line");
                if(request == "POST")
                {
                    String m = "Test POST text.";
                    DEBUG("Posting: " + m);
                    os = c.openOutputStream();
                    os.write(m.getBytes());
                    os.close();
                    os.flush();
                    java.io.DataInputStream datainputstream = c.openDataInputStream();
                }
                int rc = c.getResponseCode();
                if(rc != 200)
                {
                    b.append("Response Code: " + c.getResponseCode() + "\n");
                    b.append("Response Message: " + c.getResponseMessage() + "\n\n");
                }
                is = c.openInputStream();
                DEBUG("is = " + is);
                if(c instanceof HttpConnection)
                    len = c.getLength();
                DEBUG("len = " + len);
                if(len != -1L)
                {
                    DEBUG("Content-Length: " + len);
                    for(int i = 0; (long)i < len; i++)
                    {
                        if((ch = is.read()) == -1)
                            continue;
                        if(ch <= 32)
                            ch = 32;
                        b.append((char)ch);
                        count++;
                        if(count > 200L)
                            break;
                    }
     
                } else
                {
                    byte data[] = new byte[100];
                    int n = is.read(data, 0, data.length);
                    for(int i = 0; i < n; i++)
                    {
                        ch = data[i] & 0xff;
                        b.append((char)ch);
                    }
     
                }
                try
                {
                    if(is != null)
                        is.close();
                    if(c != null)
                        c.close();
                }
                catch(Exception ce)
                {
                    DEBUG("Error closing connection");
                }
                try
                {
                    len = is.available();
                    DEBUG("Inputstream failed to throw IOException after close");
                }
                catch(IOException io)
                {
                    DEBUG("expected IOException (available())");
                    io.printStackTrace();
                }
                t = new TextBox("Http Test", b.toString(), b.length(), 0);
                is = null;
                c = null;
            }
            catch(IOException ex)
            {
                ex.printStackTrace();
                DEBUG(ex.getClass().toString());
                DEBUG(ex.toString());
                DEBUG("Exception reading from http");
                if(c != null)
                {
                    try
                    {
                        String s = null;
                        if(c instanceof HttpConnection)
                            s = c.getResponseMessage();
                        DEBUG(s);
                        if(s == null)
                            s = "No Response message";
                        t = new TextBox("Http Error", s, s.length(), 0);
                    }
                    catch(IOException e)
                    {
                        e.printStackTrace();
                        String s = e.toString();
                        DEBUG(s);
                        if(s == null)
                            s = ex.getClass().getName();
                        t = new TextBox("Http Error", s, s.length(), 0);
                    }
                    try
                    {
                        c.close();
                    }
                    catch(IOException ioexception) { }
                } else
                {
                    t = new TextBox("Http Error", "Could not open URL", 128, 0);
                }
            }
            catch(IllegalArgumentException ille)
            {
                t = new TextBox("Illegal Argument", ille.getMessage(), 128, 0);
            }
            catch(Exception e)
            {
                t = new TextBox("Error", e.toString(), 128, 0);
            }
            if(is != null)
                try
                {
                    is.close();
                }
                catch(Exception exception) { }
            if(c != null)
                try
                {
                    c.close();
                }
                catch(Exception exception1) { }
            setCommands(t, false);
            display.setCurrent(t);
        }
    Thanks,
    Kobi Toueg

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Symbian V2 HTTP connection problem with WAP+Proxy

    Are you GETting or POSTing? Or does it make no difference?

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    5

    Re: Symbian V2 HTTP connection problem with WAP+Proxy

    We are POSTing.

    Regards,
    Kobi Toueg

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Symbian V2 HTTP connection problem with WAP+Proxy

    And... does a GET work?

    If it does, try setting the content-length for the posted content.

Similar Threads

  1. N95 problem - '?' removed from url when HTTP Connection opened
    By hoodarakesh in forum Mobile Java Networking & Messaging & Security
    Replies: 8
    Last Post: 2008-09-16, 09:06
  2. http connection via a proxy programmatically
    By tiansun in forum Mobile Java General
    Replies: 0
    Last Post: 2005-04-19, 02:47
  3. Replies: 2
    Last Post: 2003-02-19, 03:10
  4. Http connection Problem on 6610
    By tangxj in forum Mobile Java General
    Replies: 0
    Last Post: 2002-12-23, 01:15

Posting Permissions

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