我嘗試爲android構建一個https客戶端,我需要獲得Servlet的一些請求 但是當我使用getInputStream方法時,應用程序掛起。httpsURLConnection.getInputStream()掛起
只有當我打電話給方法時,纔會出現錯誤。
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();
}
這只是檢查呼叫,但它沒有工作。 任何想法爲什麼它掛起,並告訴我什麼?
訂閱方法的作品,當我註釋輸入流的行,服務器顯示我都是正確的。 我可以嘗試與Firefox一樣,它的工作原理,我可以看到請求。
我還將密鑰庫放入TrustManager中。
對不起,我的英語我希望我解釋它ennougth。
THX
你的主線程或不同線程上這樣做呢? – Falmarri 2010-08-16 18:33:45
您是否在客戶端安裝了證書? – Vinay 2010-08-17 06:46:04