[JAVA-3094] How to handle MongoSocketReadException Created: 15/Nov/18 Updated: 27/Oct/23 Resolved: 15/Nov/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Leo Han | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Comments |
| Comment by Jeffrey Yemin [ 07/Jan/20 ] |
|
Note also that as of the 3.11 release, the driver also supports retryable reads (retryReads=true in the connection string. Also note that as of the 3.11 release, retryable reads and retryable writes are enabled by default. |
| Comment by Jeffrey Yemin [ 15/Nov/18 ] |
|
To reiterate, the immediate cause is that the MongoDB server shut down or crashed, or there was a failure somewhere in the network layer. If you enable retryable writes (retryWrites=true in the connection string), the driver will attempt to retry the write on your behalf. For reads, you'll have to catch the exception and execute the retry in the application. Hope this helps. I'm going to close this issue now, as the driver is working as designed. |
| Comment by Leo Han [ 15/Nov/18 ] |
|
Hi jeff.yemin, thanks for the input. In my program I have to put some read and write operations in the loop, is this likely to be the cause of this error? Regards,Leo |
| Comment by Jeffrey Yemin [ 15/Nov/18 ] |
|
You're getting the following exception: Caused by: com.mongodb.MongoSocketReadException: Prematurely reached end of stream. This typically happens when the MongoDB server is shut down, and does not indicate a bug in the driver. If your application needs to be resilient to server restarts, crashes or transient network failures, there are a few things you can do:
|
| Comment by Leo Han [ 15/Nov/18 ] |
|
Hi jeff.yemin I uploaded the log file,And I have set the parameters of the connection pool, as follows
|
| Comment by Jeffrey Yemin [ 15/Nov/18 ] |
|
HI leohanchn@gmail.com looks like you hit enter prematurely. Please comment on what the error is, and I'll update the description. Or let me know that you didn't intend to file this issue, and I'll close it out. Regards, |