连接到机器时的Java套接字异常

时间:2019-02-18 11:21:10

标签: java exception io rest-assured

我很放心地发送一些帖子请求,但是,偶尔我会遇到I / O异常

我的应用程序在远程计算机上运行,​​我正在尝试使用http通过rest api发布一些请求。在某些情况下,应用程序会响应,但我在连接时遇到问题。

这是java输出。

Feb 20, 2019 4:37:13 PM org.apache.http.impl.client.DefaultHttpClient tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://hostnane:8080: Software caused connection abort: socket write error
Feb 20, 2019 4:37:13 PM org.apache.http.impl.client.DefaultHttpClient tryExecute
INFO: Retrying request to {}->http://hostname:8080
Feb 20, 2019 4:37:13 PM org.apache.http.impl.client.DefaultHttpClient tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://hostname:8080: Software caused connection abort: socket write error
Feb 20, 2019 4:37:13 PM org.apache.http.impl.client.DefaultHttpClient tryExecute
INFO: Retrying request to {}->http://hostname:8080
Feb 20, 2019 4:37:13 PM org.apache.http.impl.client.DefaultHttpClient tryExecute
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://hostnamet:8080: Software caused connection abort: socket write error
Feb 20, 2019 4:37:13 PM org.apache.http.impl.client.DefaultHttpClient tryExecute
INFO: Retrying request to {}->hostnamet:8080
 public RequestSpecification createAndSendReq(String authorization_input, String pathname_input) {
        RequestSpecification request = RestAssured.given();
        request.auth().none();
        request.header("Accept", "application/json").
                and().header("Authorization", authorization_input).
                and().header("Content-Type", "multipart/form-data");
        request.multiPart(new File(pathname_input));
        request.body("type: application");
        //request.log().headers();
        return request;

 RequestSpecification request_401 = createAndSendReq(authorization, pathname);
        Response response_401 = request_401.post(ssc_path);

编辑


在客户端和服务器上检查了请求和响应后,似乎可以进行通信。

服务器-使用tcpdump的端口8080输出

.y      .............#a.P....1..POST /ssc/api/v1/plugins HTTP/1.1^M
Authorization: xxx^M
Accept: application/json^M
Content-Length: 2388159^M
Content-Type: multipart/form-data; boundary=AI6ww0uqAtnxDHyDLy5Xc5_4b7vh2GBLF71Jtj9e^M
Host: host:8080^M
Connection: Keep-Alive^M
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_192)^M
Accept-Encoding: gzip,deflate^M
^M
--AI6ww0uqAtnxDHyDLy5Xc5_4b7vh2GBLF71Jtj9e^M
Content-Disposition: form-data; name="file"; filename="filename"^M
Content-Type: application/octet-stream^M
Content-Transfer-Encoding: binary^M

客户 enter image description here

唯一的问题是为什么java / testng框架将其视为无效测试(抛出异常)?

0 个答案:

没有答案