简体   繁体   English

当发送沉重的json将近5MB时,它将给我java.net.SocketException:连接被同级重置:套接字写入错误

[英]While sending heavy json almost 5MB it will give me java.net.SocketException: Connection reset by peer: socket write error

would like to post a huge JSON object, but when i try i got this error: 想发布一个巨大的JSON对象,但是当我尝试时出现此错误:

java.net.SocketException: Connection reset by peer: socket write error
 at java.net.SocketOutputStream.socketWrite0(Native Method)
 at java.net.SocketOutputStream.socketWrite(Unknown Source)
 at java.net.SocketOutputStream.write(Unknown Source)
 at org.apache.http.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:126)
 at org.apache.http.impl.io.SessionOutputBufferImpl.write(SessionOutputBufferImpl.java:162)
 at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:115)
 at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:122)
 at org.apache.http.entity.StringEntity.writeTo(StringEntity.java:169)
 at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:158)
 at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:162)
 at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:237)
 at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:122)
 at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:271)
 at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
 at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
 at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
 at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107)
 at com.os.util.helper.microServiceHelper.AbstractMicroServiceHelper.getResultFromMicroServices(AbstractMicroServiceHelper.java:196)
 at com.os.util.helper.microServiceHelper.IsheetVersionMicroserviceImpl.bulkInsertUpdateIsheetVersion(IsheetVersionMicroserviceImpl.java:75)
 at com.os.gfnactions.isheet.IsheetVersionPutInMicroserviceThread.run(IsheetVersionPutInMicroserviceThread.java:36)
 at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
 at java.util.concurrent.FutureTask.run(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)

Socket Exception 套接字异常

When I am sending a large heavy json through HttpClient Post request it will give me a below error. 当我通过HttpClient Post请求发送大型沉重的json时,它将出现以下错误。

so how to solve below error i was study all posted question.but doesn't get a proper solution for my error. 所以如何解决下面的错误我正在研究所有发布的问题。但是没有为我的错误找到合适的解决方案。

FYI : Basically we are use spring boot api at server side. 仅供参考:基本上,我们在服务器端使用spring boot api。 we are call that api from a application which is in java. 我们从Java中的应用程序调用该api。

can you please anyone help me solve below error?? 能否请任何人帮我解决以下错误?

1) How to send from client side in java ? 1)如何在Java中从客户端发送?

2) How to get server side that json in java ? 2)如何在Java中获取服务器端的json?

You should try increase socket timeout by typing socket.setSoTimeout(number) 您应该尝试通过键入socket.setSoTimeout(number)增加套接字超时。

Documentation: https://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#setSoTimeout(int) 文档: https : //docs.oracle.com/javase/7/docs/api/java/net/Socket.html#setSoTimeout(int)

Posting huge text it's not good idea. 发布大量文字不是一个好主意。 You should apply some pagination for this and split eg. 您应该为此应用一些分页并拆分例如。 every 200kb. 每200kb。

For big json files I recommend BSON http://bsonspec.org/ 对于大型json文件,我建议BSON http://bsonspec.org/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.net.socketexception connection reset by peer socket write error 通过Jenkins在Tomcat7上部署war时(使用Maven) - java.net.socketexception connection reset by peer socket write error While deploying war on Tomcat7 through Jenkins (Using Maven) ClientAbortException:java.net.SocketException:由peer重置连接:套接字写入错误 - ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error java.net.SocketException: Connection reset by peer: socket write error 提供文件时 - java.net.SocketException: Connection reset by peer: socket write error When serving a file “ java.net.SocketException:对等体重置连接:套接字写入错误”我该如何解决 - “java.net.SocketException: Connection reset by peer: socket write error” How can I solve it java.net.SocketException:对等连接重置:传输音频时套接字写入错误 - java.net.SocketException: Connection reset by peer: socket write error When transmitting Audio ClientAbortException:java.net.SocketException:对等重置连接:套接字写入错误 - ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error (java.net.SocketException) 在处理请求时被捕获:连接被对等重置:套接字写入错误 - (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error Influxdb-java:org.influxdb.InfluxDBIOException:java.net.SocketException:通过对等方重置连接:套接字写入错误 - influxdb-java: org.influxdb.InfluxDBIOException: java.net.SocketException: Connection reset by peer: socket write error 我收到 java.net.SocketException: Connection reset by peer: socket write error ,当在类截图中执行主函数时 - I am getting java.net.SocketException: Connection reset by peer: socket write error ,when executing main function in class screenshot 错误java.net.SocketException:连接重置 - ERROR java.net.SocketException: Connection reset
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM