java.net.SocketException: Connection reset

1,977 views
Skip to first unread message

Vineet Saini

unread,
Aug 30, 2011, 1:53:47 AM8/30/11
to mongodb-user
Hi,
In one of our application we are facing the intermittent issue of
connection reset while doing the upsert operations.
Attached the complete exception trace.

We are using the mongo replica set, we are having the mongo on
separate host and java app server on separate host.
Following are the mongo options which we have defined -

mongoOptions.autoConnectRetry = true;
mongoOptions.connectionsPerHost = 60;
mongoOptions.connectTimeout = 120000;

Exception message:

com.mongodb.MongoException$Network: can't say something
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:159)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:132)
at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:343)
at com.mongodb.DBCollection.update(DBCollection.java:150)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:
96)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at org.bson.io.PoolOutputBuffer.pipe(PoolOutputBuffer.java:129)
at com.mongodb.OutMessage.pipe(OutMessage.java:160)
at com.mongodb.DBPort.go(DBPort.java:108)
at com.mongodb.DBPort.go(DBPort.java:82)
at com.mongodb.DBPort.findOne(DBPort.java:142)
at com.mongodb.DBPort.runCommand(DBPort.java:151)
at com.mongodb.DBPort.checkAuth(DBPort.java:301)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:145)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:132)
at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:343)
at com.mongodb.DBCollection.update(DBCollection.java:150)

Have any body faced similar issue, or anybody knows what could be the
potential root cause of the problem.

Thanks

Nat

unread,
Aug 30, 2011, 2:09:22 AM8/30/11
to mongod...@googlegroups.com
Did you connect over WAN? If not, did you see anything in mongod log? It seems like the connection is not stable or the server disconnects it.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Vineet Saini

unread,
Aug 30, 2011, 12:15:33 PM8/30/11
to mongodb-user
yes we connect over WAN.

I have not seen any errors on mongod.

I have tried following mongo option, looks like the issue is resolved
after setting the below options.

I am not seeing these errors now.

mongoOptions.socketKeepAlive = true;

Scott Hernandez

unread,
Aug 30, 2011, 12:18:08 PM8/30/11
to mongod...@googlegroups.com
It might also be good to reduce the timeout period if you see it
again. Some operating system can have it pretty high (7200secs).
http://www.mongodb.org/display/DOCS/Troubleshooting#Troubleshooting-Socketerrorsinshardedclustersandreplicasets

Vineet Saini

unread,
Sep 1, 2011, 1:56:55 AM9/1/11
to mongodb-user
Scott, I am again observing the same exceptions in my java side.
I dont see any exception or error message at mongo logs.

I have looked at the TCP Socket Live setting its 7200 in my mongo
hosts and same as in App server hosts.

Could you please elaborate more on this point as how it could be the
potential cause of these exceptions at Java side.

Thanks
Vineet

On Aug 30, 9:18 am, Scott Hernandez <scotthernan...@gmail.com> wrote:
> It might also be good to reduce the timeout period if you see it
> again. Some operating system can have it pretty high (7200secs).http://www.mongodb.org/display/DOCS/Troubleshooting#Troubleshooting-S...

Vineet Saini

unread,
Sep 1, 2011, 1:56:33 AM9/1/11
to mongodb-user
Scott, I am again observing the same exceptions in my java side.
I dont see any exception or error message at mongo logs.

I have looked at the TCP Socket Live setting its 7200 in my mongo
hosts and same as in App server hosts.

Could you please elaborate more on this point as how it could be the
potential cause of these exceptions at Java side.

Thanks
Vineet

On Aug 30, 9:18 am, Scott Hernandez <scotthernan...@gmail.com> wrote:
> It might also be good to reduce the timeout period if you see it
> again. Some operating system can have it pretty high (7200secs).http://www.mongodb.org/display/DOCS/Troubleshooting#Troubleshooting-S...

Nat

unread,
Sep 1, 2011, 7:06:18 AM9/1/11
to mongod...@googlegroups.com
It's possible that some routers may drop TCP connections when there is no data sending/receiving for a certain period. do you have a lot of requests when it happens?

Scott Hernandez

unread,
Sep 1, 2011, 9:16:47 AM9/1/11
to mongod...@googlegroups.com
Have you tried reducing this to 300, as the link/page describes? If
so, did you still get an error?

Vineet Saini

unread,
Sep 1, 2011, 1:11:30 PM9/1/11
to mongodb-user
@Nat, I am seeing these errors during the load test, so lots of
request are going around 10-15 request/sec.
@Scott, I have not tried reducing it to 300, I will try that option
and will see if I still get these errors.

Thanks

Vineet Saini

unread,
Sep 1, 2011, 5:26:11 PM9/1/11
to mongodb-user
before the above exception, I am seeing following errors in the
Application server logs -

Aug 30, 2011 9:53:35 PM com.mongodb.DBPortPool gotError
WARNING: emptying DBPortPool to <host>:10900 b/c of error
java.net.SocketException: Connection reset
at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
at java.net.SocketOutputStream.write(SocketOutputStream.java:
136)
at org.bson.io.PoolOutputBuffer.pipe(PoolOutputBuffer.java:
129)
at com.mongodb.OutMessage.pipe(OutMessage.java:160)

After that I get the socket reset exception in the DB transactions.
Reply all
Reply to author
Forward
0 new messages