Unable to publish grandnode where mongodb is database

Bhanu Pratap Singh 1 Reputation point

I have published my asp.netcore app which uses mongodb as database from visual studio, but while installing it, it is unable to create database or may be error while connecting database,

error is as given below:
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 : "2", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 2, EndPoint : "Unspecified/grandnodemongo.mongo.cosmos.azure.com:10255" }", EndPoint: "Unspecified/grandnodemongo.mongo.cosmos.azure.com:10255", 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-05-11T22:55:10.4489871Z" }] }.

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,058 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
4,946 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Ubezzi 2,771 Reputation points

    Wanted to provide information about publishing .NET web applications with the Azure Cosmos DB API for MongoDB. The tutorial demonstrates how to update the connection string in the project (see: update connection string). The following section details how to install the MongoDB driver (see: run the web app). The next step would be to publish the solution to Azure App Service, as the Quickstart has you build and run the solution locally in Visual Studio while connected to your Azure Cosmos DB API for MongoDB instance remotely.

    Quickstart: Build a .NET web app using Azure Cosmos DB's API for MongoDB (link)

    For information on how to publish a web application to Azure App Service, please see the following: Publish a Web app to Azure App Service using Visual Studio. The difference between a non Cosmos DB based web application and a Cosmos DB API for MongoDB based web application is the driver and connection string reference in the code base where a non Cosmos DB web app uses web.config and the connection string entry in the App Service settings.

    Please make sure your solution has the correct driver installed and the code base includes the connection string. If you can run the solution locally in Visual Studio and connect to the remote instance of the Cosmos DB API for MongoDB then the solution should run in the App Service environment. The only item that would prevent connectivity would be firewall related (public endpoint versus selected network endpoint).

    0 comments No comments