Android的HTTP连接 - 多个设备无法连接在同一台服务器 [英] Android http connection - multiple devices cannot connect the same server

查看:388
本文介绍了Android的HTTP连接 - 多个设备无法连接在同一台服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的需要帮助这里...

I really need help here...

我有一个简单的Andr​​oid应用程序,连接到我断绝通过HTTPS来获取数据。

I have a simple Android application that connects to my sever to fetch data over HTTPS.

一切工作正常,直到我连接到其他设备(iOS或Android)在同一台服务器。我开始得到超时或连接被拒绝,或根据我使用(有时SSL握手)

Everything is working fine up until i connected to the same server from another device (iOS or Android). I am starting to get timeouts or connection refused or other errors depending on the library that I use (sometimes SSL handshake)


  1. 我试过同一路由器上2 Android应用 - 失败

  1. I tried 2 android app on the same router - fails

我试过排球,改造,普通HTTP库 - 失败

I tried Volley, Retrofit, plain http library - fails

如果一个设备通过蜂窝网络和一个在WiFi连接,这是工作的罚款。不过,我已经看到它未能甚至使用连接到蜂窝网络,而不是无线设备2例。

if one device is connected via cellular network and one on wifi, it is working fine. However, i have seen cases that it fails even using 2 devices connected to cellular network and not wifi.

这是很容易复制。一个应用程序工作正常。只要我在另一台设备上完成的操作。第一个应用程序将无法连接。

It is easy to reproduce. one app is working fine. as soon as i do an operation on the other device. the first app will not be able to connect.

iOS应用。没有失败

iOS app using the same api/server is working fine. no failures

我出现故障时跑在Android应用程式的Wireshark并收到以下内容:

I ran wireshark on the android app during failure and received the following:

70 47.073286 10.0.0.1 10.0.0.138 120 ICMP不可达的目标(端口不可达)

70 47.073286 10.0.0.1 10.0.0.138 ICMP 120 Destination unreachable (Port unreachable)

好像端口的问题。我不知道了,如果这是服务器问题还是客户问题.. iOS应用程序工作正常。没有问题。只有Android系统。

Seems like port issues. I am not sure anymore if this is a server issue or a client issue.. iOS app works fine. no issues. Only Android.

我试过:

System.setProperty("http.keepAlive", "false");

我试图设置一个HTTP头连接:关闭没有什么作品...

任何想法是AP preciated ...

Any idea would be appreciated...

推荐答案

确切有同样的问题,并花了很多时间来调查,没有任何帮助,包括重用连接的旗帜,试图还禁用tcp_timestamp,tcp_tw_reuse,tcp_tw_recycle并启用作为这里建议为应用程序虚拟机的安全模式:

Had exact the same issue and spent a lot of time investigating, nothing helped including "Reuse connection" flag, tried also to disable tcp_timestamp, tcp_tw_reuse, tcp_tw_recycle and enable vm safe mode for the app as suggested here:

  • https://github.com/square/okhttp/issues/903
  • https://github.com/square/okhttp/issues/1037
  • https://github.com/square/okhttp/issues/1518

但都在静脉。

进一步,很奇怪的是,我有我做完全一样的,以追查问题,一台服务器没有任何问题。

Further more, the very strange thing was that I had two different instances/servers which I made exactly the same in order to track down the issue and one server didn't have any issues.

那么到底:

实例重启解决问题的连接。
  (或只需要重新启动网络服务)

Instance reboot solved problem with connections. (or just need to restart networking service)

(三)我的服务器/实例管理

(c) My server/instance admin

这篇关于Android的HTTP连接 - 多个设备无法连接在同一台服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆