tags:

views:

119

answers:

2

Hi all,

i try to build an https client for android and i need do get some request of an Servlet but when i use the getInputStream method the applicaion hangs.

There is no error only hanging when i call the method.

    String url = "https://.../Servlet";

  try {
   mPushLiteConnection = (HttpsURLConnection) new URL(url).openConnection();
   mPushLiteConnection.setDoOutput(true);
   mPushLiteConnection.setDoInput(true);
   mPushLiteConnection.setRequestMethod("POST");
   mPushLiteConnection.connect();

   subscribe();

   InputStream in = (InputStream)mPushLiteConnection.getInputStream();

   unsubscribe();

   mPushLiteConnection.disconnect();

  } catch (MalformedURLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

this is only to check the call, but it didtn work. Any idea why it hangs and tell me nothing?

the subscribe method works, when i comment out the line with the inputstream, the server show me all is correct. I can try the same with the Firefox and it works and i can see the request.

i also put the keystore into the TrustManager.

sorry for my english i hope i explain it ennougth.

THX

+1  A: 

i use a different Thread and yes i installed the certificate on the client side

i have a second connection to load a list from another servlet and it works fine, but i dont need a InputStream for it only a SAX Parser. But i cant use the SAX Parser for this servlet, couse i dont get an XML, only XML Tags without the Start Document Tag

maybie you know how to ignore the Start Document tag? I am not sure if i need it for SAX

Mirko
Ok... when it hangs and i kill the server it goes oni think the InputStream Blocks end never ends couse the Servlet is an Push Servlet it never ends with sending requests
Mirko
+1  A: 

I think i know the reason! the method getInputStream() needs (why ever) the contentLength! In the servlet i want to connect to is no contentLength couse it is an push chunked servlet... it sends all the time pieces of XML without length.

So.. HttpsURLConnection are not usefull for chunked!

Now i try the same connection with httpClient i hope it works for it... if not: i jump behind the bus ;)

Mirko