Android 10中的服务器连接问题

问题描述 投票:1回答:1

我们正在尝试与“ HttpsURLConnection”对象进行服务器通信,其中我们已将请求对象的“ connection”属性设置为“ close” [[setRequestProperty(“ Connection”,“ close”)]] >。直到在所有设备的Android 9 OS中都可以正常使用上述设置,在某些使用Android 10 OS的设备中(例如:具有Android 10的Samsung A70),我们遇到的是“ java.net。 ConnectException“。当我们删除Connection属性时,服务器通信已建立并解决了该问题。我需要您的支持来理解根本原因,原因为何Android 10 OS会发生行为更改,并且通过删除连接对象会产生任何影响]

url = new URL(reqURL);
httpsConnection = url.openConnection();
httpsConnection.setRequestMethod("POST");
httpsConnection.setRequestProperty("Content-Language", "en");
httpsConnection.setRequestProperty("Connection", "close");
httpsConnection.setRequestProperty("Content-Type","application/text");
OutputStream os = httpsConnection.getOutputStream();
os.write(cvmesgToServer.getBytes()) httpsConnection.connect();

[我们正在尝试与“ HttpsURLConnection”对象进行服务器通信,其中我们已将请求对象的“ connection”属性设置为“ close” [setRequestProperty(“ Connection”,“ close”)]]。 ...

android connection android-10.0 httpsurlconnection
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.