×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    2

    Angry Error in HTTP operation

    Hi,

    i'm developing a midlet which should run on several handies. So i decided to use J2mePolish to build it simultanously for Nokia 6230, 6230i, Siemens etc...
    The MIDLET runs on Siemens real device and 6230-Emulator ( successfully )
    But trying to run it on 6230i doesn't failed with the following Exception:
    java.io.IOException: Error in HTTP operation

    This is what i see on eclipse:
    [j2mepolish] Nokia/6230i: Method : POST
    [j2mepolish] Nokia/6230i: write0 length=54 data =
    [j2mepolish] Nokia/6230i: loading url=http://127.0.0.1:8080/servlet/MyServlet
    [j2mepolish] Nokia/6230i: Exception: java/io/IOException
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.checkForException(+31)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.readResponseMessage_wap(+28)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.connect_wap(+402)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.connect(+27)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol$PrivateOutputStream.flush(+21)
    [j2mepolish] Nokia/6230i: at java.io.DataOutputStream.flush(+7)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.model.Networker.submitRequest(+247)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.controller.MyNetWorker.run(+19)
    [j2mepolish] Nokia/6230i: Exception: java/io/IOException
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.checkForException(+31)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.readResponseMessage_wap(+28)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.connect_wap(+402)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.connect(+27)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol$PrivateOutputStream.flush(+21)
    [j2mepolish] Nokia/6230i: at java.io.DataOutputStream.flush(+7)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.model.Networker.submitRequest(+247)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.controller.MyNetWorker.run(+19)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.checkForException(+31)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.readResponseMessage_wap(+28)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.connect_wap(+402)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol.connect(+27)
    [j2mepolish] Nokia/6230i: at com.sun.midp.io.j2me.http.Protocol$PrivateOutputStream.flush(+21)
    [j2mepolish] Nokia/6230i: at java.io.DataOutputStream.flush(+7)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.model.Networker.submitRequest(+247)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.controller.MyNetWorker.run(+19)
    [j2mepolish] Nokia/6230i: Exception: java/lang/Exception
    [j2mepolish] Nokia/6230i: at de.myapp.midp.model.Networker.submitRequest(+318)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.controller.MyNetWorker.run(+19)
    [j2mepolish] Nokia/6230i: Exception: java/lang/Exception
    [j2mepolish] Nokia/6230i: at de.myapp.midp.model.Networker.submitRequest(+318)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.controller.MyNetWorker.run(+19)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.model.Networker.submitRequest(+318)
    [j2mepolish] Nokia/6230i: at de.myapp.midp.controller.MyNetWorker.run(+19)

    I use the following statments to make a http-connection:

    ...
    HttpConnection conn = null;
    DataInputStream hdin = null;
    DataOutputStream hdout = null;
    Parameter params = Parameter.getInstance();
    try {
    conn = (HttpConnection) Connector.open( url );
    conn.setRequestMethod(HttpConnection.POST);
    hdout = conn.openDataOutputStream();

    hdout.writeInt(OpCodes.ACTION); // Submit opcode
    hdout.writeUTF(params.param1);
    hdout.writeUTF(params.param2);
    hdout.writeUTF((param.param2);
    hdout.writeUTF(params.param3);

    hdout.flush();

    hdin = conn.openDataInputStream();
    response = hdin.readUTF();

    } catch (Exception e) {
    resetSession ();
    e.printStackTrace();
    throw new Exception ("AILURE ");
    } finally {
    try {
    if (conn != null) conn.close();
    if (hdout != null) hdout.close();
    if (hdin != null) hdin.close();
    } catch (Exception e) {}
    }
    }
    ....


    Idon't understand why the midlet is running on siemens, Nokia 6230 and not on 6230i. I don't use any special api, i used standard http and compraed it with the source code from the book of Michael Yuan and it didn't find any differences.
    Please tell, if ther is anything to take in account between 6230 and 6230i.
    What did i wrong?

    Thank you for a soon reply

    Fethi

  2. #2
    Registered User
    Join Date
    Aug 2006
    Posts
    1

    Re: Error in HTTP operation

    Have you tried playing with removing flush() call to see if this make any difference?
    -midpman

  3. #3
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Error in HTTP operation

    Hi Fethi,

    Are you sure the URL below will be accessible from real device?

    "http://127.0.0.1:8080/servlet/MyServlet"

    Are you talking about emulators or real devices?

    Juarez Jr

  4. #4
    Registered User
    Join Date
    Jun 2007
    Posts
    10

    Re: Error in HTTP operation

    Hello,
    I am trying to open a connection to a server and read some data from my midlet. The code looks like this:

    final String baseUrl = "http://129.187.150.138/";
    final String memoUrl = baseUrl+"?tag=0";

    try{
    conn = HttpConnectionHelper.connect(memoUrl);
    conn.setRequestMethod(HttpConnection.GET);
    is = conn.openInputStream();
    .......
    }...

    I get javax.microedition.io.connectionNotFoundException: TCP open on my emulator and "Error in HTTP operation" on my cellphone. (I can connect to this site and get the data with "Internet" application on my device (6131).
    Does anybody knows what is the problem?
    Thanks!

  5. #5
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Error in HTTP operation

    Hi,

    Please post the code for the class below as it is a custom class and it is where you are really creating your connection.

    HttpConnectionHelper.connect(memoUrl)

    Br,
    Juarez Alvares Barbosa Junior - Brazil

  6. #6
    Registered User
    Join Date
    Jun 2007
    Posts
    10

    Re: Error in HTTP operation

    Hello!
    I got the solution!
    In "Preferred Access Point" nothing was selected. I selected the service, and it works fine now on the cellphone. Although I still get that message in emulator. The code is in a normal method in one of my classes. (a Normal Class) Should I do something in my emulator setting maybe?
    Cheers,
    Pujan

  7. #7
    Registered User
    Join Date
    Jul 2007
    Posts
    2

    Re: Error in HTTP operation

    I already have configured an Access Point and now the midlet show an alert "Subscribe to packet data first", and then shows the IOException: Error in HTTP operation, what else can I do???

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

    Re: Error in HTTP operation

    My guess is that the APN is not properly configured. What phone model are you talking about?
    See also here
    http://forum.nokia.com/document/Foru...figuration.htm

    Hartti

  9. #9
    Registered User
    Join Date
    Aug 2007
    Posts
    9

    Angry Re: Error in HTTP operation

    I'm am currently trying to make a connection between a midlet on a 6131 and a servlet.
    This code was running under other mobile phone but is not working on 6131. I have tried it both on the mobile phone and on the emulator (I'm not sure that it works great...)

    the code is:

    c = (HttpConnection) Connector
    .open("http://mysite.com/myservlet");
    c.setRequestMethod(HttpConnection.POST);
    os = (DataOutputStream)c.openDataOutputStream();
    String str = this.toBeUploaded;
    os.writeUTF(str);
    os.flush();
    is = c.openDataInputStream();
    String res = is.readUTF();


    visibly the "flush" does'nt work. I get a "error in http operation" on the mobile phone

    Do you have any idea?

    Thanks in advance.

  10. #10
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Error in HTTP operation

    Hi colombeh,

    Please create your own threads and do not hijack ones posted by other people.

    Anyway, have you followed Hartti's advice on the thread you have hijacked? Check if you have the access point configured properly on the Nokia 6131 device.

    Hope this helps.
    Juarez Alvares Barbosa Junior - Brazil

  11. #11
    Regular Contributor
    Join Date
    Apr 2007
    Location
    Bangalore, India
    Posts
    81

    Re: Error in HTTP operation

    HI,

    For "Subscribe to packet data first", problem u have to subscribe for GPRS.

Similar Threads

  1. Replies: 2
    Last Post: 2006-10-06, 17:24
  2. HTTP Client - Synchronous HTTP POST Calls?
    By symbian_ravi in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2006-04-16, 11:51
  3. HTTP Communication (MIDP 1.0 required but not implemented?)
    By asphalt_world in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2005-08-13, 12:02
  4. error in http operation on 6822
    By samy_rdissi in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-06-28, 17:23
  5. http connection via a proxy programmatically
    By tiansun in forum Mobile Java General
    Replies: 0
    Last Post: 2005-04-19, 02:47

Posting Permissions

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