Jetty HttpClent错误“;java.util.concurrent.ExecutionException:org.eclipse.jetty.io.EOFEException;

Jetty HttpClent错误“;java.util.concurrent.ExecutionException:org.eclipse.jetty.io.EOFEException;,java,jetty,httpclient,Java,Jetty,Httpclient,我目前正在开发一个模块,其中我使用Jetty HttpClient将JSON格式的数据发送到服务器端运行的REST服务 简而言之,用例: 我有一个包含10000个条目的CSV文件 需要将CSV条目转换为Java POJO对象,然后转换为JSON格式 将转换后的JSON格式发送到服务器端运行的RESTWeb服务 它还应该执行身份验证过程,同时使用RESTWeb服务调用将JSON格式的数据发送到服务器 问题: 如果我尝试发送所有10000个条目以及身份验证过程,我会得到以下异常: java.util

我目前正在开发一个模块,其中我使用Jetty HttpClient将JSON格式的数据发送到服务器端运行的REST服务

简而言之,用例:

  • 我有一个包含10000个条目的CSV文件
  • 需要将CSV条目转换为Java POJO对象,然后转换为JSON格式
  • 将转换后的JSON格式发送到服务器端运行的RESTWeb服务
  • 它还应该执行身份验证过程,同时使用RESTWeb服务调用将JSON格式的数据发送到服务器
  • 问题: 如果我尝试发送所有10000个条目以及身份验证过程,我会得到以下异常:

    java.util.concurrent.ExecutionException:org.eclipse.jetty.io.EOFEException 位于org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118) 位于org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101) 位于org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:653)
    原因:org.eclipse.jetty.io.EofException
    位于org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:192) 位于org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:408) 位于org.eclipse.jetty.io.WriteFlusher.completeWrite(WriteFlusher.java:364) 在org.eclipse.jetty.io.SelectChannelEndPoint.onSelected上(SelectChannelEndPoint.java:111) 位于org.eclipse.jetty.io.SelectorManager$ManagedSelect.processKey(SelectorManager.java:636) 在org.eclipse.jetty.io.SelectorManager$ManagedSelector.select(SelectorManager.java:607) 位于org.eclipse.jetty.io.SelectorManager$ManagedSelect.run(SelectorManager.java:545) 位于org.eclipse.jetty.util.thread.NonBlockingThread.run(NonBlockingThread.java:52) 位于org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) 位于org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) 在java.lang.Thread.run(未知源)
    原因:java.io.IOException:主机中的软件中止了已建立的连接
    位于sun.nio.ch.SocketDispatcher.write0(本机方法) at sun.nio.ch.SocketDispatcher.write(未知源) 位于sun.nio.ch.IOUtil.writeFromNativeBuffer(未知源) at sun.nio.ch.IOUtil.write(未知源) at sun.nio.ch.socketchannelpl.write(未知来源) 位于org.eclipse.jetty.io.ChannelEndPoint.flush(ChannelEndPoint.java:170)
    ... 10多

    批量转换10000个条目 如果我成批转换所有10000个条目(例如,10个条目的成批转换)。我能够成功地用相同的URL和身份验证过程发送数据

    参考所需的代码如下所示:

            String user = "myuser";
            String passwd = "mypassword";
            String relm = "Realm";
    
            String URL = "http://localhost:9123/path/to/rest/service/";
    
            HttpClient httpClient = new HttpClient();
            httpClient.start();
    
            httpClient.setConnectTimeout(10000);
    
            Gson gson = new Gson();
    
            String content = gson.toJson();
    
            AuthenticationStore authentication = httpClient.getAuthenticationStore();
            BasicAuthentication basicAuth = new BasicAuthentication(new URI(URL), relm, user, passwd);
            authentication.addAuthentication(basicAuth);
    
            StringContentProvider contentProvider = new StringContentProvider("application/json", content, StandardCharsets.UTF_8);
    
            Request request = httpClient.newRequest(tURL);
            request.method(HttpMethod.POST);
            request.content(contentProvider);
            ContentResponse response = request.send();
    
            //ContentResponse response = httpClient.newRequest(URL).method(HttpMethod.POST).content(contentProvider).send();
    
            int status = response.getStatus();
    
            String reason = response.getReason();
    
            logger.info("REASON IS :: " + reason);
            logger.info("RESPONSE STATUS :: " + status);
    

    请帮助我解决此问题。

    什么版本的HttpClient?感谢Joakim的回复。我目前正在使用jetty-all-9.2.10.v20150310 JAR文件来使用HttpClient。我对9.2.22.V20170606什么版本的HttpClient有相同的问题?感谢Joakim的回复。我目前正在使用jetty-all-9.2.10.v20150310 JAR文件来使用HttpClient。我与9.2.22.v20170606有相同的问题