[CSHARP-2645] SocketException: An operation on a socket could not be performed Created: 21/Jun/19 Updated: 22/Jul/19 Resolved: 22/Jul/19 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 2.8.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Austin Felipe | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Azure Win 10 (App services) - S1 1.75 GB |
||
| Description |
|
Hi guys. I'm running a stress test with JMeter and I'm facing the following error:
JMeter setup is: 100 threads in parallel The error occurs around the 8th round. It seems Windows is running out of ports to handle requests, but my question is: shouldn't sockets be reused? In my head I thought that since the maximum parallel requests count is 100, it should use 100 ports only.
My Mongo client config (it's called once per application lifetime):
My socket config:
|
| Comments |
| Comment by Robert Stam [ 28/Jun/19 ] | ||||||||||||||||||||||||||
|
Sorry I misinterpreted now many `MongoClient` instances you were using. If you could provide a self contained `Program.cs` file that reproduces this that would be a tremendous help. | ||||||||||||||||||||||||||
| Comment by Austin Felipe [ 25/Jun/19 ] | ||||||||||||||||||||||||||
|
Is there anything I could provide to help? | ||||||||||||||||||||||||||
| Comment by Austin Felipe [ 24/Jun/19 ] | ||||||||||||||||||||||||||
|
Robert Stam, thanks for answering. Well, actually I'm using one MongoClient per lifetime as I said on my post. That was a bad code formatting:
That code is called once on Startup class. Each repository is using this CacheDatabase class which has:
Any idea? | ||||||||||||||||||||||||||
| Comment by Robert Stam [ 24/Jun/19 ] | ||||||||||||||||||||||||||
|
Normally when you create a new instance of `MongoClient` it shares an underlying connection pool with all other `MongoClient` instances that have the same settings. It looks like because you are using a `SocketConfigurator` the driver is unable to tell that all the `MongoClient` instances are compatible, in which case each new `MongoClient` instance would create a new connection pool. My suggestion would be to create a single global `MongoClient` instance and have all your threads share it. | ||||||||||||||||||||||||||
| Comment by Austin Felipe [ 22/Jun/19 ] | ||||||||||||||||||||||||||
|
Code formatting is wrong, sorry about that guys. I'm not sure I can edit it. |