gpt4 book ai didi

java - 获取 java.net.SocketException : recvfrom failed: ECONNRESET (Connection reset by peer)

转载 作者:太空狗 更新时间:2023-10-29 16:03:58 28 4
gpt4 key购买 nike

<分区>

我是安卓新手。通过 HttpClient 更新时出现错误,如 java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)

public static String newupdateProf(String memid, String gender,
String pdata, String dob, String pimg) throws IOException,
JSONException {
// System.setProperty("http.keepAlive", "false");
final HttpClient httpClient = new DefaultHttpClient();
final HttpPost httpost = new HttpPost(websrv.trim() + "/newUpdtProf");

JSONStringer img = new JSONStringer().object().key("prof").object()
.key("memid").value(memid.trim()).key("gender")
.value(gender.trim()).key("pdata").value(pdata.trim())
.key("dob").value(dob.trim()).key("pimg").value(pimg.trim())
.endObject().endObject();
StringEntity se = new StringEntity(img.toString());
httpost.setEntity(se);
httpost.setHeader("Accept", "application/json");
httpost.setHeader("Content-type", "application/json");

HttpResponse httpResponse = httpClient.execute(httpost);

HttpEntity httpEntity = httpResponse.getEntity();

InputStream stream = httpEntity.getContent();
String result = convertStreamToString(stream);
return result.trim();

}

请帮帮我。我也试过了

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

但它不起作用。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com