Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    5

    Problem with Http Post

    Hi, I have problem posting some data (approximately 150KB) on Nokia Asha 1.1 SDK Simulator as well as on a real Asha 503 device. The same code works flawlessly on previous Asha phones and simulators. The problem is that it takes really long time to complete (approximately 3 minutes) . While debugging I found that the problem line is where the connection gets the response code (http.getResponseCode()). I checked the server if the request is received but there is no data reaching the server before these 3 minutes. For some reason the code execution stops at http.getResponseCode() for 2-3 minutes and I can't figure out why is that. Please check my code below and tell me if you have any clues. Thanks in advance.

    Code:
    http = (HttpConnection)Connector.open(URL);
    http.setRequestMethod(HttpConnection.POST);
    http.setRequestProperty("User-Agent", USER_AGENT);
    http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
    
    out = http.openOutputStream();
    out.write(params.getBytes()); //params contain 139 783 bytes of data
    out.flush();
    if (http.getResponseCode() == HttpConnection.HTTP_OK) //here is the hang
    {
    	//do something with the response
    }

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,571

    Re: Problem with Http Post

    Instead of single, huge HTTP POST, how about doing a multipart/chunked post (Transfer-Encoding: chunked)?

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Problem with Http Post

    Just to make sure its not a network issue, can you check once on WIFI and another with operator connection?
    its just doesn't seem realistic that it would take 3 min even if its just 1 "huge" (150kb isn't huge at all) post, could there be a delay in the server execution?
    Heard of DVLUP? Join here

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,808

    Re: Problem with Http Post

    A thing you can also try is specifying a Content-Length header.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    5

    Re: Problem with Http Post

    Thanks to all for the replies Setting Content-Length doesn't help. It's not operator problem because I test this on Simulator and on real device with 2 WiFi hotspots. I don't think 150 KB is huge amount of data even for phones like Asha 501/503. As I told this code run perfectly on previous Asha devices like 306/311.

    According to this post "HTTPConnection has a new implementation":
    http://developer.nokia.com/community...n-Asha-SDK-1-0

    Is it possible this is a bug in this "new implementation"?

  6. #6
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: Problem with Http Post

    Like wizard-hu was advising in that other discussion you might want to try to intercept the data with WireShark and see if you are getting a response right away from the server, and if so if the data is starting to flow right away...
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  7. #7
    Registered User
    Join Date
    Nov 2012
    Posts
    5

    Re: Problem with Http Post

    It seems that only part of the post data is transmitted and after this the connection hangs. The server timeouts after N seconds and returns status 200 OK but the data received is only partial.
    Maybe the new HTTPConnection implementation has a limitation of the size when posting data?
    Last edited by kmudovich; 2014-02-12 at 14:14.

  8. #8
    Registered User
    Join Date
    Nov 2012
    Posts
    5

    Re: Problem with Http Post

    Anyone who has a clue?

  9. #9
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Problem with Http Post

    If you can arrange for a compiled test midlet I can help you test it on my devices and let you know if the results are the same
    and then we can take it from there.
    Heard of DVLUP? Join here

  10. #10
    Registered User
    Join Date
    Nov 2012
    Posts
    5

    Re: Problem with Http Post

    It seems to be a problem with output stream flush in the new implementation of HTTPConnection when data size is more than 50KB . Didn't succeed to find the reason for this. Finally resolved my problem by using JazzLib to compress the data and Content-Encoding: gzip.

  11. #11
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Problem with Http Post

    Compressing is the write approach as it reduces the data cost and network traffic as well and the other solution would be use a multipart HTTP request (which is often used to send large data files to server).

    For info on multipart HTTP request - http://www.developer.nokia.com/commu...oad_in_Java_ME
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. HTTP POST problem
    By rami75lu in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2010-10-21, 10:06
  2. HTTP post(ing) problem
    By sohan in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-03-28, 09:48
  3. http post problem
    By ceehira in forum Symbian
    Replies: 0
    Last Post: 2006-07-28, 13:49
  4. HTTP POST Problem with SDK's
    By tonyhabayeb in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2006-06-16, 13:41
  5. HTTP POST Problem
    By Rx-lee in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2006-05-30, 04:58

Posting Permissions

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