A connection attempt failed error when accessing MongoDB under load test - mongodb

We're beginning to leverage MongoDB for search functionality in our application, to improve performance over how we used to do searches with SQL Server. Individual testing works fine, however now we've begun load testing with 40 concurrent "users" executing searches against MongoDB at once. Part way through each load test, many of the calls start erroring:
MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server. ---> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytes(Stream stream, Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer()
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer()
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.ConnectionPools.ExclusiveConnectionPool.AcquiredConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`1 protocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](ICoreSession session, ReadPreference readPreference, DatabaseNamespace databaseNamespace, BsonDocument command, IEnumerable`1 commandPayloads, IElementNameValidator commandValidator, BsonDocument additionalOptions, Action`1 postWriteAction, CommandResponseHandling responseHandling, IBsonSerializer`1 resultSerializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle channel, ICoreSessionHandle session, ReadPreference readPreference, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelSource channelSource, ICoreSessionHandle session, ReadPreference readPreference, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Operations.AggregateOperation`1.Execute(IReadBinding binding, CancellationToken cancellationToken)
at MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle session, IReadOperation`1 operation, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.Aggregate[TResult](IClientSessionHandle session, PipelineDefinition`2 pipeline, AggregateOptions options, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.<>c__DisplayClass19_0`1.<Aggregate>b__0(IClientSessionHandle session)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.Aggregate[TResult](PipelineDefinition`2 pipeline, AggregateOptions options, CancellationToken cancellationToken)
at RealtorsPropertyResource.Rpr.MongoSearches.Model.QueryPropertiesForKeys[T](PerformanceMonitor performanceMonitor, PropertiesSearchCriteria criteria, RequiredDataResult requiredData)
at RealtorsPropertyResource.Rpr.MongoSearches.Model.SearchWithMongo(PropertiesSearchCriteria criteria, PerformanceMonitor performanceMonitor)
at RealtorsPropertyResource.Rpr.MongoSearches.Model.SearchForProperties(PropertiesSearchCriteria criteria, PerformanceMonitor performanceMonitor, Nullable`1 useMongo)
at RealtorsPropertyResource.Rpr.Websites.Main.AjaxService.ExecuteLoadTestSearch(AppPropertyMode appPropertyMode, SearchType searchType, String query) in C:\BuildAgents\RPR-Website\_work\4\s\Websites\Main\services\AjaxService.Search.cs:line 260
at SyncInvokeExecuteLoadTestSearch(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
We tested against two Mongo instances, one running on Windows and one running on Linux, and both are hitting this error. The searches that are completing successfully aren't slow, so I'm not confident this is a timeout issue, but perhaps maybe a max connection issue? I'm confused though because I thought the default connection limit for the MongoDB C# driver was 100 connections, and that limit for the MongoDB server itself was much higher than that.
Any suggestions of how to troubleshoot this error that only occurs while Mongo is under load?
In case it's relevant, here is how I'm instantiating a singleton MongoClient and IMongoDatabase:
public static class MongoContext
{
private static bool initialized = false;
private static string connectionString { get; set; }
private static IMongoDatabase database;
public static IMongoDatabase Database
{
get
{
if (database == null)
throw new InvalidOperationException("You must initialize the MongoContext first");
return database;
}
}
public static void Initialize()
{
if (!initialized)
{
initialized = true;
connectionString = RprConfigurationManager.GetConnectionString("MongoSearch");
Console.WriteLine("Connecting to MongoDB search database: " + connectionString);
var useSsl = connectionString.IndexOf("ssl=true", StringComparison.InvariantCultureIgnoreCase) >= 0;
var url = new MongoUrl(connectionString);
var clientSettings = MongoClientSettings.FromUrl(url);
clientSettings.SslSettings = new SslSettings();
clientSettings.SslSettings.CheckCertificateRevocation = false;
clientSettings.UseSsl = useSsl;
clientSettings.VerifySslCertificate = false;
var client = new MongoClient(clientSettings);
var lastSegment = connectionString.Split('/').Last();
var databaseSegments = lastSegment.Split('?');
var databaseName = databaseSegments.First();
databaseName = !String.IsNullOrEmpty(databaseName) ? databaseName : "rpr";
Console.WriteLine("Connecting to database: " + databaseName);
database = client.GetDatabase(databaseName);
SchemaInitializer.RegisterClassMaps();
}
}
}
Here are some mongod logs, in case it helps:
IXSCAN { CityPlaceId: 1, ForSaleGroupId: 1, DistressedGroupId: 1,
OffMarketGroupId: 1, ForLeaseGroupId: 1, ForSaleDistressedGroupId: 1,
OffMarketDistressedGroupId: 1, OrgId: 1, OrgSecurableId: 1,
OffMarketDate: 1, IsListingOnly: 1 } keysExamined:397707
docsExamined:332738 hasSortStage:1 cursorExhausted:1 numYields:20750
nreturned:1 reslen:1454 locks:{ Global: { acquireCount: { r: 21121 }
}, Database: { acquireCount: { r: 21121 } }, Collection: {
acquireCount: { r: 21121 } } } storage:{ data: { bytesRead:
7534883557, timeReadingMicros: 325960940 } } protocol:op_msg 356835ms
2019-08-19T19:43:08.856+0000 I NETWORK [conn285] Error sending
response to client: SocketException: An established connection was
aborted by the software in your host machine.. Ending connection from
172.27.129.209:65121 (connection id: 285) 2019-08-19T19:43:08.856+0000 I NETWORK [conn285] end connection 172.27.129.209:65121 (30
connections now open)

Here is mentioned that can be a problem with the driver, In our case we change the driver version from 2.5 to 2.10 and worked.

Related

MailKit version 2.15.0 disconnection issue

I am using MailKit version 2.15.0. When trying to disconnect the client using DisconnectAsync, I am getting the below error
ClientDisconnect method()==> Exception Message: The ReadAsync method cannot be called when another read operation is pending., Exception String: System.NotSupportedException: The ReadAsync method cannot be called when another read operation is pending.
at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer)
at MailKit.Net.Pop3.Pop3Stream.ReadAheadAsync(Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Pop3.Pop3Stream.ReadLineAsync(Stream ostream, Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Pop3.Pop3Engine.ReadLineAsync(Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Pop3.Pop3Engine.ReadResponseAsync(Pop3Command pc, Boolean doAsync)
at MailKit.Net.Pop3.Pop3Engine.IterateAsync(Boolean doAsync)
at MailKit.Net.Pop3.Pop3Client.SendCommandAsync(Boolean doAsync, CancellationToken token, String command)
at MailKit.Net.Pop3.Pop3Client.DisconnectAsync(Boolean quit, Boolean doAsync, CancellationToken cancellationToken)
Below is the code I am using to Disconnect the Client
private async Task DisconnectClient(Hashtable markAsRead, EmailServer emailServer)
{
pollingInProgress = false;
await emailServer.ClientDisconnect(markAsRead);
markAsRead.Clear();
}
internal void MarkAsRead(Hashtable markAsRead)
{
emailBinding.emailSource().MarkRead(markAsRead);
}
internal async Task ClientDisconnect(Hashtable markAsRead)
{
try
{
if (!emailBinding.emailSource().IsConnected)
{
await emailBinding.Connect();
}
FlushClient(markAsRead);
await emailBinding.Disconnect();
}
catch (Exception e)
{
AttachWorkerLogs(string.Format("ClientDisconnect method()==> Exception Message: {0}, Exception String: {1}", e.Message, e.ToString()));
throw;
}
}
private void FlushClient(Hashtable markAsRead)
{
MarkAsRead(markAsRead);
}
Finally calling the disconnect method like this:
public async Task Disconnect()
{
try
{
if (client.IsConnected)
{
await client.DisconnectAsync(true);
}
}
catch (Exception e)
{
AttachLogger(string.Format("Disconnect method()==> Exception Message: {0}, Exception String: {1}", e.Message, e.ToString()));
throw;
}
}
I am unable to figure out what exactly is the issue.
The exception message makes it pretty clear that you are trying to read from the SslStream from multiple threads at the same time.
Since MailKit is not multi-threaded, it means that you are effectively trying to perform 2 or more operations on the same Pop3Client from multiple threads at the same time.
In other words, the problem is not that you are calling Disconnect, the problem is that you are calling Disconnect when your code is also trying to download messages or something from the server.

getting 500 error by calling any route which is getting data from database in azure-web-app-service

recently i have deployed my .net 5.0 api in azure web app without azure database. The app is running fine but i am not able to call any route which is getting data from my postgresql database. The api and getting data from my database is working fine in my local pc, but when i call any route in azure web app i get 500 internal server error and the detail error look like this.
error #1
Category: Microsoft.EntityFrameworkCore.Database.Connection
EventId: 20004
SpanId: 81307fd2722df04f
TraceId: 17283bbac7e9c74ab0dea8dafdf0a12a
ParentId: 0000000000000000
ConnectionId: 0HMB63E788EM6
RequestId: 0HMB63E788EM6:00000004
RequestPath: /api/someList
ActionId: d26cb19d-75cd-4847-828f-a74e2b5324ee
ActionName: QuranApi.Controllers.QuranTextController.GetSomeList (MyApi)
An error occurred using the connection to database 'MyDatabase' on server
'tcp://localhost:5432'.
error #2
Category: Microsoft.EntityFrameworkCore.Query
EventId: 10100
SpanId: 81307fd2722df04f
TraceId: 17283bbac7e9c74ab0dea8dafdf0a12a
ParentId: 0000000000000000
ConnectionId: 0HMB63E788EM6
RequestId: 0HMB63E788EM6:00000004
RequestPath: /api/someList
ActionId: d26cb19d-75cd-4847-828f-a74e2b5324ee
ActionName: QuranApi.Controllers.QuranTextController.GetSomeList (MyApi)
An exception occurred while iterating over the results of a query for context type
'QuranApi.PostgreSqlContext'.
System.InvalidOperationException: An exception has been raised that is likely due to
a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Sockets.SocketException (10013): An attempt was made to access a
socket in a way forbidden by its access permissions.
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async,
CancellationToken cancellationToken)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async,
CancellationToken cancellationToken)
at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout
timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnection.Open()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.
OpenDbConnection(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean
errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean
errorsExpected)
at
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.
ExecuteReader(RelationalCommandParameterObject parameterObject)at
Microsoft.EntityFrameworkCore.Query.Internal.
SingleQueryingEnumerable`1.Enumerator.
InitializeReader(DbContext _, Boolean result)at
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.
NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation,
Func`3 verifySucceeded)
--- End of inner exception stack trace ---
at
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.
NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation,
Func`3 verifySucceeded)at Microsoft.EntityFrameworkCore.Query.Internal.
SingleQueryingEnumerable`1.Enumerator.MoveNext()
Exception:
System.InvalidOperationException: An exception has been raised that is likely due to
a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Sockets.SocketException (10013): An attempt was made to access a
socket in a way forbidden by its access permissions.
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Connect(NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.RawOpen(NpgsqlTimeout timeout, Boolean async,
CancellationToken cancellationToken)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async,
CancellationToken cancellationToken)
at Npgsql.ConnectorPool.OpenNewConnector(NpgsqlConnection conn, NpgsqlTimeout
timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.ConnectorPool.<>c__DisplayClass38_0.<<Rent>g__RentAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnection.<>c__DisplayClass41_0.<<Open>g__OpenAsync|0>d.MoveNext()
--- End of stack trace from previous location ---
at Npgsql.NpgsqlConnection.Open()at
Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean
errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean
errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean
errorsExpected) at
Microsoft.EntityFrameworkCore.Storage.RelationalCommand.
ExecuteReader(RelationalCommandParameterObject parameterObject)
at
Microsoft.EntityFrameworkCore.Query.Internal.
SingleQueryingEnumerable`1.Enumerator.InitializeReader(DbContext _, Boolean result)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.
Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
--- End of inner exception stack trace ---
at
Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.
Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at
Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.
Enumerator.MoveNext()
error #3
Category: Microsoft.AspNetCore.Server.Kestrel
EventId: 13
SpanId: 81307fd2722df04f
TraceId: 17283bbac7e9c74ab0dea8dafdf0a12a
ParentId: 0000000000000000
ConnectionId: 0HMB63E788EM6
RequestId: 0HMB63E788EM6:00000004
RequestPath: /api/someList
Connection id "0HMB63E788EM6", Request id "0HMB63E788EM6:00000004": An unhandled
exception was thrown by the application.
Exception:
System.InvalidOperationException: An exception has been raised that is likely due to
a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Exception while connecting
---> System.Net.Sockets.SocketException (10013): An attempt was made to access a
socket in a way forbidden by its access permissions.
my Program.cs File
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseUrls("https://localhost:5000", "https://IP-Address-of-my-PC")
.UseIISIntegration()
.UseStartup<Startup>();
});
}
And my Startup.cs File
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
var sqlConnectionString = Configuration["ConnectionString"];
services.AddDbContext<PostgreSqlContext>(options =>
options.UseNpgsql(connectionString: sqlConnectionString));
services.AddScoped<IDataAccessProvider, DataAccessProvider>();
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1",
new OpenApiInfo
{
Title = "MyApi",
Version = "v1"
});
});
}
// This method gets called by the runtime.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseSwagger();
app.UseSwaggerUI(options =>
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyApi v1"));
}
}
i would be very happy if anybody can help me with this. I dont know what to do.

System.ArgumentException: Keyword not supported: minimumpoolsize (Parameter 'keyword') use PostgreSQL

I Created a new project(apb 4.2.2) with EF+PostgreSQL. then i have been changed connection string in appsettings.json for match my postgresql db. EX.
"ConnectionStrings": {
"Default": "Host=localhost;Port=5432;Database=psi_pg_dev;User ID=chaoyi;Password=123456;Pooling=true;MinimumPoolSize=0;MaximumPoolSize=100;Connection Lifetime=0;"
},
when run this project, i get a problem messages below:
08:53:21 ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Abp.BackgroundJobs.EntityFrameworkCore.BackgroundJobsDbContext'.
System.ArgumentException: Keyword not supported: minimumpoolsize (Parameter 'keyword')
at Npgsql.NpgsqlConnectionStringBuilder.GetProperty(String keyword)
at Npgsql.NpgsqlConnectionStringBuilder.set_Item(String keyword, Object value)
at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
at Npgsql.NpgsqlConnectionStringBuilder..ctor(String connectionString)
at Npgsql.NpgsqlConnection.GetPoolAndSettings()
at Npgsql.NpgsqlConnection.set_ConnectionString(String value)
at Npgsql.NpgsqlConnection..ctor(String connectionString)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlRelationalConnection.CreateDbConnection()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection()
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.CreateDbCommand(RelationalCommandParameterObject parameterObject, Guid commandId, DbCommandMethod commandMethod)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
then i attempt to deleted about pool settings in connection string. and i still got a problem below:
"ConnectionStrings": {
"Default": "Host=localhost;Port=5432;Database=psi_pg_dev;User ID=chaoyi;Password=123456"
},
09:17:58 ERR] Failed executing DbCommand (18ms) [Parameters=[#__now_0='?' (DbType = DateTime), #__p_1='?' (DbType = Int32)], CommandType='Text', CommandTimeout='30']
SELECT a."Id", a."ConcurrencyStamp", a."CreationTime", a."ExtraProperties", a."IsAbandoned", a."JobArgs", a."JobName", a."LastTryTime", a."NextTryTime", a."Priority", a."TryCount"
FROM "AbpBackgroundJobs" AS a
WHERE NOT (a."IsAbandoned") AND (a."NextTryTime" <= #__now_0)
ORDER BY a."Priority" DESC, a."TryCount", a."NextTryTime"
LIMIT #__p_1
[09:17:58 ERR] An exception occurred while iterating over the results of a query for context type 'Volo.Abp.BackgroundJobs.EntityFrameworkCore.BackgroundJobsDbContext'.
Npgsql.PostgresException (0x80004005): 42P01: relation "AbpBackgroundJobs" does not exist
at Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
Exception data:
Severity: ERROR
SqlState: 42P01
MessageText: relation "AbpBackgroundJobs" does not exist
Position: 186
File: parse_relation.c
Line: 1376
Routine: parserOpenTable
Npgsql.PostgresException (0x80004005): 42P01: relation "AbpBackgroundJobs" does not exist
at Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
Exception data:
Severity: ERROR
SqlState: 42P01
MessageText: relation "AbpBackgroundJobs" does not exist
Position: 186
File: parse_relation.c
Line: 1376
Routine: parserOpenTable
[09:17:58 ERR] 42P01: relation "AbpBackgroundJobs" does not exist
Npgsql.PostgresException (0x80004005): 42P01: relation "AbpBackgroundJobs" does not exist
at Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Volo.Abp.BackgroundJobs.EntityFrameworkCore.EfCoreBackgroundJobRepository.GetWaitingListAsync(Int32 maxResultCount)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Volo.Abp.BackgroundJobs.BackgroundJobStore.GetWaitingJobsAsync(Int32 maxResultCount)
at Volo.Abp.BackgroundJobs.BackgroundJobWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
at Volo.Abp.BackgroundWorkers.AsyncPeriodicBackgroundWorkerBase.DoWorkAsync()
Exception data:
Severity: ERROR
SqlState: 42P01
MessageText: relation "AbpBackgroundJobs" does not exist
Position: 186
File: parse_relation.c
Line: 1376
Routine: parserOpenTable
[09:17:58 ERR] ---------- Exception Data ----------
Severity = ERROR
InvariantSeverity = ERROR
SqlState = 42P01
MessageText = relation "AbpBackgroundJobs" does not exist
Position = 186
File = parse_relation.c
Line = 1376
Routine = parserOpenTable
Plz, how can i fixed that. :) thanks all.
If you use services.AddDbContextPool<... so poolSize has default preset - max 128. Thus, just remove from con string MinimumPoolSize=0;MaximumPoolSize=100;
Relevant for .Net Core 5, EF Core 5, Postgres 13
The rest errors you shuold fix according to errors info.

MongoDB cannot connect once in Azure - asp core 3.1 - Visual Studio 2019

My application runs just fine with MongoDB string when I run it locally, it can connect to the remote mongoDB database, to add/retrieve data just fine.
"MyDatabaseSettings": {
"ConnectionString": "mongodb+srv://admin:<PWD>#cluster0-7yxfg.mongodb.net/<DBNAME>?retryWrites=true&w=majority&connect=replicaSet"},
However, as soon as I publish to Azure, I get a connection error as show below.
If I comment out the access to MongoDB in the code then the whole app works fine on Azure too. It really seems to be because of the access to MongoDB. Do I need to declare some specific IP or do more MongoDB setup in Azure? I was under the impression that the string of connection would do the trick and that it would just work once deployed in Azure too...
An unhandled exception occurred while processing the request.
TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/cluster0-shard-00-00-7yxfg.mongodb.net:27017" }", EndPoint: "Unspecified/cluster0-shard-00-00-7yxfg.mongodb.net:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(Int32 responseTo, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageAsync(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.IsMasterHelper.GetResultAsync(IConnection connection, CommandWireProtocol1 isMasterProtocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.ConnectionInitializer.InitializeConnectionAsync(IConnection connection, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2020-08-30T20:31:47.3607137Z" }, { ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/cluster0-shard-00-01-7yxfg.mongodb.net:27017" }", EndPoint: "Unspecified/cluster0-shard-00-01-7yxfg.mongodb.net:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(Int32 responseTo, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageAsync(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.IsMasterHelper.GetResultAsync(IConnection connection, CommandWireProtocol1 isMasterProtocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.ConnectionInitializer.InitializeConnectionAsync(IConnection connection, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2020-08-30T20:31:47.4624960Z" }, { ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/cluster0-shard-00-02-7yxfg.mongodb.net:27017" }", EndPoint: "Unspecified/cluster0-shard-00-02-7yxfg.mongodb.net:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
---> System.IO.EndOfStreamException: Attempted to read past the end of the stream.
at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync()
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(Int32 responseTo, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageAsync(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.IsMasterHelper.GetResultAsync(IConnection connection, CommandWireProtocol1 isMasterProtocol, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.ConnectionInitializer.InitializeConnectionAsync(IConnection connection, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken)
at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2020-08-30T20:31:47.4406769Z" }] }.
MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
Stack Query Cookies Headers Routing
TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/cluster0-shard-00-00-7yxfg.mongodb.net:27017" }", EndPoint: "Unspecified/cluster0-shard-00-00-7yxfg.mongodb.net:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream. at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync() --- End of inner exception stack trace --- at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync() at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(Int32 responseTo, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageAsync(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken) at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.IsMasterHelper.GetResultAsync(IConnection connection, CommandWireProtocol1 isMasterProtocol, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.ConnectionInitializer.InitializeConnectionAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) --- End of inner exception stack trace --- at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2020-08-30T20:31:47.3607137Z" }, { ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/cluster0-shard-00-01-7yxfg.mongodb.net:27017" }", EndPoint: "Unspecified/cluster0-shard-00-01-7yxfg.mongodb.net:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream. at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync() --- End of inner exception stack trace --- at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync() at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(Int32 responseTo, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageAsync(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken) at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.IsMasterHelper.GetResultAsync(IConnection connection, CommandWireProtocol1 isMasterProtocol, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.ConnectionInitializer.InitializeConnectionAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) --- End of inner exception stack trace --- at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2020-08-30T20:31:47.4624960Z" }, { ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/cluster0-shard-00-02-7yxfg.mongodb.net:27017" }", EndPoint: "Unspecified/cluster0-shard-00-02-7yxfg.mongodb.net:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server. ---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server. ---> System.IO.EndOfStreamException: Attempted to read past the end of the stream. at MongoDB.Driver.Core.Misc.StreamExtensionMethods.ReadBytesAsync(Stream stream, Byte[] buffer, Int32 offset, Int32 count, TimeSpan timeout, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync() --- End of inner exception stack trace --- at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync() at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBufferAsync(Int32 responseTo, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessageAsync(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken) at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.IsMasterHelper.GetResultAsync(IConnection connection, CommandWireProtocol1 isMasterProtocol, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.ConnectionInitializer.InitializeConnectionAsync(IConnection connection, CancellationToken cancellationToken) at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) --- End of inner exception stack trace --- at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelperAsync(CancellationToken cancellationToken) at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2020-08-30T20:31:47.4406769Z" }] }.
MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
MongoDB.Driver.Core.Clusters.Cluster+WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)
MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)
MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken)
MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken)
MongoDB.Driver.MongoClient.StartImplicitSession(CancellationToken cancellationToken)
MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken)
MongoDB.Driver.MongoCollectionImpl.UsingImplicitSession(Func<IClientSessionHandle, TResult> func, CancellationToken cancellationToken)
MongoDB.Driver.MongoCollectionImpl.FindSync(FilterDefinition filter, FindOptions<TDocument, TProjection> options, CancellationToken cancellationToken)
MongoDB.Driver.FindFluent<TDocument, TProjection>.ToCursor(CancellationToken cancellationToken)
MongoDB.Driver.IAsyncCursorSourceExtensions.ToList(IAsyncCursorSource source, CancellationToken cancellationToken)
Traveller.Classes.TSPUtilsDb.TSPUtilsDb_GetAtlas(DocumentService iDocService, TSPAtlas iAtlas, string iDbName, string iCollectionName) in TSPUtils.cs
Traveller.Controllers.DefinitionController.OnActionExecuting(ActionExecutingContext iContext) in DefinitionController.cs
Microsoft.AspNetCore.Mvc.Controller.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
Microsoft.AspNetCore.Mvc.Filters.ControllerActionFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, object state, bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Show raw exception details

An existing connection was forcibly closed by the remote host. in WCF using database first approach

I'm trying to display data in a table format, by joining two tables 'Users' and 'Company' with Foreign key relation.
When I directly writes the code in controller with working fine
public ActionResult Index()
{
var model = new UserModel();
model.Users = db.Users
.OrderBy(o => o.CreatedBy)
.Include(c => c.Company).ToList();
return View(model);
}
but when i place the same code in WCF is throwing exception..
public List GetUsersList()
{
try
{
using (ProductionEntities db = new ProductionEntities())
{
db.Configuration.LazyLoadingEnabled = false;
db.Configuration.ProxyCreationEnabled = false;
IQueryable<User> _users = db.Users
.OrderBy(o => o.CreatedBy)
.Include(c => c.Company);
return _users.ToList();
}
}
catch (Exception ex)
{
ExceptionData exceptionData = new ExceptionData();
exceptionData.ErrorMessage = "Error in GetUsersList";
exceptionData.ErrorDetails = ex.ToString();
throw new FaultException<ExceptionData>(exceptionData, ex.Message);
}
}
The below is the Stack Trace Inner exception :
InnerException: System.Net.WebException
HResult=-2146233079
Message=The underlying connection was closed: An unexpected error occurred on a receive.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
InnerException: System.IO.IOException
HResult=-2146232800
Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Source=System
StackTrace:
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=An existing connection was forcibly closed by the remote host
Source=System
ErrorCode=10054
NativeErrorCode=10054
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
Any idea???
Thank you,
That's due to the circular reference.
Check this link for Reference
also we need to set
ProductionEntities db = new ProductionEntities()
db.Configuration.LazyLoadingEnabled = false;
db.Configuration.ProxyCreationEnabled = false;