https 在 tmobile android 上超慢(使用 httpclient.execute 方法)
我有一个应用程序,它对我编写的 REST Web 服务进行多次调用。我注意到,当我添加 SSL 时,网络调用的执行时间从 <1 秒缩短到约 3 秒。添加SSL后正常吗?我使用 Droid、HTC Thunderbolt 和三星平板电脑(均在 Verizon 上)测量了时间。
真正疯狂的是: 每当在 TMobile 网络(Comet 和 Nexus)上使用电话时,这些相同的呼叫(通过 HTTP)每次都需要 30-40 秒。如果我删除 SSL,这些相同的调用将像其他设备一样花费 <1 秒。关于 TMobile 设备上的 SSL 为何出现此问题的任何线索?我被难住了?
代码:
String url = BASE_URL + path;
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter("http.socket.timeout", new Integer(30000));
httpclient.getParams().setParameter("setSocketBufferSize", 8192);
HttpPost httppost = new HttpPost(url);
httppost.addHeader("Content-Type", "text/json");
InputStream istream = null;
try {
httppost.setEntity(new StringEntity(request.toString()));
HttpResponse response = httpclient.execute(httppost);
istream = response.getEntity().getContent();
String result = IOUtils.toString(istream);
...
I have an application that makes numerous calls to REST web services I have written. I have noticed in general that when I added SSL the web calls went from <1 sec to ~3sec to execute. Is that normal when adding SSL? I have measured the times using the Droid, HTC Thunderbolt, and Samsung Tablet (all on Verizon).
What is really CRAZY is:
whenever using a phone on the TMobile network (Comet and Nexus) those same calls (over HTTPs) take 30-40 seconds each. If I remove SSL those same calls take <1s just like the other devices. Any clue as to why SSL on the TMobile devices is having this issues? I am stumped?
Code:
String url = BASE_URL + path;
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter("http.socket.timeout", new Integer(30000));
httpclient.getParams().setParameter("setSocketBufferSize", 8192);
HttpPost httppost = new HttpPost(url);
httppost.addHeader("Content-Type", "text/json");
InputStream istream = null;
try {
httppost.setEntity(new StringEntity(request.toString()));
HttpResponse response = httpclient.execute(httppost);
istream = response.getEntity().getContent();
String result = IOUtils.toString(istream);
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论