Question

I'm seeing a ton of these errors

"An existing connection was forcibly closed by the remote host"

in the Mongo log since I switched from the open source c# driver to the 10Gen supported one. Once this error happens my websites become unresponsive. I have a feeling it has something to do with the way connection pooling is implemented. See log below, I'm deleting indexes from a collection, removing all items, then 'recreating' the collection by adding all the rows I want and then re indexing the collection. A few moments after that is all done I invariably get the error : 'An existing connection was forcibly closed by the remote host'

[conn46] run command admin.$cmd { ismaster: 1 }
[conn46] query admin.$cmd ntoreturn:1 command: { ismaster: 1 } reslen:64 0ms
[conn46] query BtSearchCache.system.indexes reslen:1407 nreturned:7 0ms

drop indexes
[conn46] run command BtSearchCache.$cmd { deleteIndexes: "Board_41", index: "ix_QuickSearch" }
[conn46] CMD: dropIndexes BtSearchCache.Board_41
[conn46] dropIndexes: ix_QuickSearch not found
[conn46] query BtSearchCache.$cmd ntoreturn:1 command: { deleteIndexes: "Board_41", index: "ix_QuickSearch" } reslen:81 1ms

remove all data from collection
[conn46] remove  query: {} 1428ms

insert data (thousands of rows, omitted here)

[conn46] insert BtSearchCache.Board_41 0ms
[conn46] insert BtSearchCache.Board_41 0ms
[conn46] insert BtSearchCache.Board_41 1ms
[conn46] insert BtSearchCache.Board_41 0ms
[conn46] insert BtSearchCache.system.indexes 0ms

create indexes
[conn46] run command admin.$cmd { getlasterror: 1 }
[conn46] query admin.$cmd ntoreturn:1 command: { getlasterror: 1 } reslen:65 0ms

ERROR a few minutes later
[conn46] MessagingPort recv() errno:10054 An existing connection was forcibly closed by the remote host. 192.168.100.216:51111
[conn46] SocketException: 9001 socket exception
[conn46] end connection 192.168.100.216:51111
Was it helpful?

Solution

Followup: this question was also asked in the mongodb-user group on Google and most of the discussion happened there. In the end what we found out was that a particular query was causing the mongo server to crash (the bug is already fixed in current versions of the server) and the C# driver was simply reporting the connection failures that resulted. This was not a bug in the C# driver and no fix was required to the driver. The C# driver would reconnect once the server was brought back up.

OTHER TIPS

I don't know why it is, but i know that you need restart you application in order to fix this issue. And this error always come when you restart mongodb. So after each restart of mongo db you need restart your application(i suppose you usigng iis).

If you know about mongo vue this tool also can't connect to mongodb when mongovue was restarted.

Hope this help your resolve issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top