Android httpsURLConnection.getInputStream()挂起
我尝试为android构建一个https客户端,我需要得到一些Servlet请求 但是当我使用getInputStream方法时,应用程序挂起 只有在调用该方法时才会挂起Android httpsURLConnection.getInputStream()挂起,android,https,Android,Https,我尝试为android构建一个https客户端,我需要得到一些Servlet请求 但是当我使用getInputStream方法时,应用程序挂起 只有在调用该方法时才会挂起 String url = "https://.../Servlet"; try { mPushLiteConnection = (HttpsURLConnection) new URL(url).openConnection(); mPushLiteConnection.setDoOutput(tru
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();
}
这只是为了检查电话,但没用。
你知道为什么它挂着什么都不告诉我吗
subscribe方法可以工作,当我用inputstream注释掉行时,服务器向我显示所有内容都是正确的。
我可以在Firefox上尝试同样的方法,它可以工作,我可以看到请求
我还将密钥库放入TrustManager
对不起,我的英语我希望我解释得更清楚
THX我使用不同的线程
是的,我在客户端安装了证书
我有第二个连接从另一个servlet加载列表,它工作正常,但我不需要输入流,只需要SAX解析器。
但是我不能为这个servlet使用SAX解析器,因为我没有XML,只有XML标记,没有开始文档标记
也许你知道如何忽略开始文档标签?我不确定SAX是否需要它我想我知道原因了!
getInputStream()方法需要(为什么需要)contentLength!
在我想要连接的servlet中,没有contentLength,因为它是一个推分块的servlet。。。它发送XML的所有时间段,没有长度
所以。。HttpsURLConnection不适用于分块
现在我尝试与httpClient进行相同的连接
我希望它能起作用。。。如果不是:我跳到公共汽车后面;) 您是在主线程上还是在其他线程上执行此操作?您是否在客户端安装了证书?好的。。。当它挂起并且我杀死了它继续运行的服务器时,我认为InputStream会阻止end never ends,因为Servlet是一个推送Servlet,它从不以发送请求结束