我尝试使用截击发送http请求,但收到错误
javax.net.ssl.SSLHandshakeException:连接被同级关闭
我在Google周围搜索并尝试了一些建议,但没有一个能解决我的问题。请帮助
下面是代码正在使用
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;
}
}
答案 0 :(得分:-1)
就调试JSSE而言,这是一个痛苦...
握手很可能失败,并且JSSE在大多数情况下仅向您显示最后的问题,即服务器正在关闭连接。服务器通常会在TLS警报消息中告诉您问题,但不会在异常消息中显示。
如果您安装了Wireshark或类似的东西,最简单的方法是启动一个会话并查看TLS记录(Wireshark很好地显示了它们,因此很容易识别出包含错误代码和含义的错误数据包)。
如果还没有该工具,则可以激活SSL调试,并查看STDOUT上的消息。请注意,如果您不熟悉TLS,则阅读起来会有些困难,并且-由于它是全局设置-您应确保在未建立其他TLS连接的情况下进行测试,否则会产生混合输出。要启用TLS握手调试,请设置系统属性-Djavax.net.debug=ssl:handshake