【发布时间】:2019-11-04 10:15:55
【问题描述】:
我正在尝试使用 volley 发送 http 请求,但收到错误
javax.net.ssl.SSLHandshakeException:连接被对等方关闭
我四处搜索并尝试了一些建议,但没有一个能解决我的问题。请帮忙
下面是正在使用的代码
public class volley {
static RequestQueue queue=null;
public static String TAG = "MY_VOLLEY";
volley(final String URL,
final String Text
final Context context
){
helper.log(TAG,"Started Loading");
// Instantiate the RequestQueue.
if(queue==null) {
queue = Volley.newRequestQueue(context);
}
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(
Request.Method.POST, URL, new Response.Listener<String>()
{
@Override
public void onResponse(String response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
return;
}
}
){
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
try {
params.put("message",Text);
params.put("from",From);
} catch (Exception e) {
helper.log(TAG, "Error, hash map failed");
}
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("Content-Type", "application/x-www-form-urlencoded");
return params;
}
};
// Add the request to the RequestQueue.
queue.add(stringRequest);
return;
}
}
【问题讨论】:
标签: java android ssl ssl-certificate tls1.2