We successfully installed mongodb. However when we try to connect to it from Mongo Vue we are receiving following error. Any idea how to resolve this?
Connection was refused
Unable to connect to server Frontier:27017: Element 'sysInfo' not found..
Type: MongoDB.Driver.MongoConnectionException
Stack: at MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference)
at MongoDB.Driver.MongoServer.Connect(TimeSpan timeout)
at MongoDB.Driver.MongoServer.Connect()
at MangoUI.MMongo.QSDlL5xzK686iCExThO(Object )
at MangoUI.MMongo.Open(Boolean mustWrite)
at MangoUI.MMongo.Open()
at MangoUI.MConnection.get_IsValid()
at MangoUI.WinConnect.SCOjR9kYRPerNNngykW(Object )
at MangoUI.WinConnect.btnTest_Click(Object sender, EventArgs e)
Element 'sysInfo' not found.
Type: System.Collections.Generic.KeyNotFoundException
Stack: at MongoDB.Bson.BsonDocument.get_Item(String name)
at MongoDB.Driver.MongoServerBuildInfo.FromCommandResult(CommandResult result)
at MongoDB.Driver.MongoServerInstance.LookupServerInformation(MongoConnection connection)
at MongoDB.Driver.MongoServerInstance.Connect()
at MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference)
If you are using MongoDB 3.0, it will not work. I have not been able to get a response from the company.
I am thinking support for the product has stopped and the application is never going to be upgraded.
Related
I have a Postgres db set up on a ubuntu box and on the same box I have some containers from a docker compose which trying to access the database on this box. (The Postgres/database is NOT in a container. it is installed on the box)
I can access the db fine using dbeaver and can even connect to it from the site running on my dev environment on my pc
I'm using a .net core backend to connect to the db.
I have added this to the end of my backend service in the docker compose:
extra_hosts:
- "host.docker.internal:host-gateway"
Also I have tried adjusting the connection string and nothing works
Server=host.docker.internal;Port=5432;Database=mydb;User Id=xx;Password=xx;
Server=<IP address>;Port=5432;Database=mydb;User Id=xx;Password=xx;
Server=172.17.0.1;Port=5432;Database=mydb;User Id=xx;Password=xx;
Any ideas what to do?
in the logs I can see the following error
Connection id "0HMMVM72IIA14", Request id "0HMMVM72IIA14:00000002": An unhandled exception was thrown by the application.
System.InvalidOperationException: An exception has been raised that is likely due to a transient failure.
---> Npgsql.NpgsqlException (0x80004005): Failed to connect to <IP REMOVED>:5432
---> System.TimeoutException: Timeout during connection attempt
at Npgsql.Internal.NpgsqlConnector.ConnectAsync(NpgsqlTimeout timeout, CancellationToken cancellationToken)
at Npgsql.Internal.NpgsqlConnector.RawOpen(SslMode sslMode, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken, Boolean isFirstAttempt)
I am developing a C# MVC Web API which uses MongoDb as backend.I tried connecting to my mongodb database using
MongoClient mongoClient = new MongoClient(connectionString)
where connectionstring is in format : mongodb://Username:Password#hostname.eastus.cloudapp.azure.com
Mongo db is hosted in a virtual machine in Azure.I am able to connect to the database and all works good.But I am getting frequent exceptions:
"MongoDb.driver.MongoConnectionException".An exception occurred while
receivinf a message from 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,......"
So after a bit of research I have learnt that Azure is killing idle connections and I have to set MaxConnectionIdleTime.
In order to set MaxConnectionIdleTime I decided to connect to Mongodb in the below way
var credential = MongoCredential.CreateCredential("dbname", "UserName", "Password");
var settings = new MongoClientSettings
{
Credentials = new[] { credential },
Server = new MongoServerAddress("HostName", 27017),
MaxConnectionIdleTime = new TimeSpan(0, 3, 0)
};
MongoClient mongoClient = new MongoClient(settings);
In this case I am using the same username,password combination given in the connection string which I used to connect before.
While trying to connect here I am getting inner Exception:
MongoDB.Driver.MongoAuthenticationException: "Unable to authenticate
using sasl protocol mechanism SCRAM-SHA-1".
"MongoDb.driver.MongoConnectionException".An exception occurred while receivinf a message from 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,....
The reason behind this exception is when hosted in Azure,Azure tries to kill the idle connections but the C# driver is not aware of this.The driver tries to execute queries on the killed connections without knowing the connection is not existing.
The solution that worked out for me is to set maxIdleTimeMS=45000 in connection string.
This way driver will not use a connection which has been idle for long time.
Here is the connection string that worked out for me
connectionString="Username:Password#hostname.eastus.cloudapp.azure.com/?connectTimeoutMS=30000&socketTimeoutMS=30000&waitQueueTimeoutMS=30000&maxIdleTimeMS=45000"
I have had a similar error with my Azure hosted MongoDb (Cosmos Db). It turned out to be network settings such that I had blocked all access. Changing it to Allow access from "All networks" fixed the issue.
The error is very misleading, I would have expected a connection timeout.
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/XXXX.documents.azure.com:10255" }", EndPoint:
"Unspecified/XXXX.documents.azure.com:10255", State: "Disconnected",
Type: "Unknown", HeartbeatException:
"MongoDB.Driver.MongoConnectionException: An exception occurred while
opening a connection to the server. --->
MongoDB.Driver.MongoAuthenticationException: Unable to authenticate
using sasl protocol mechanism SCRAM-SHA-1. --->
MongoDB.Driver.MongoCommandException: Command saslContinue failed: Not
Authenticated.
To troubleshot I tried from MongoDb Compass as well and that didn't work either, showing me it wasn't the code.
I'm trying to create an alarm system for my application, that will trigger when one of the services (e.g. MongoDB) is not working.
What I'm doing is, once the application is started, I shut down my MongoDB server and try to connect to it, but instead of receiving an error my application just gets stuck into the execution of the method. The server console looks like something is in execution.
My current code (coffeescript) is:
checkMongoService: ()->
mongo = Npm.require 'mongodb'
assert = Npm.require 'assert'
url = 'mongodb://....'
mongo.connect url, (err, db) ->
assert.equal null, err
console.log 'Connected correctly to server'
db.close()
return
I've also been trying by doing a simple
Meteor.users.find().count();
or using MongoInternals with
testConnection = new MongoInternals.RemoteCollectionDriver("mongodb://...);
but still same issue, when mongo is not running no error is thrown and the console stops to work. If then I start Mongo again, it will just return the result (in this case the log 'Connected correctly to server')
Something that I've noticed is if I try with meteor shell to execute testConnection = new MongoInternals.RemoteCollectionDriver("mongodb://...); I get an error "Error: failed to connect to [127.0.0.1:27017]"
TL;DR
Do you might have an idea on how I can check if mongo is reachable or do you know if I'm doing something wrong with the code above?
Try setting the timeouts to be a bit shorter than the default 30 seconds:
mongo.connect(url, {
connectTimeoutMS: 1000,
socketTimeoutMS: 1000,
reconnectTries: 1
}, function(err, db) {...}
(Full set of connection params are here)
Meteor.status().status
from the docs
This method returns the status of the connection between the client and the server. The return value is an object with the following fields:
connected (Boolean)
True if currently connected to the server. If false, changes and method invocations will be queued up until the connection is reestablished.
status (String)
Blockquote
Describes the current reconnection status. The possible values are connected (the connection is up and running), connecting (disconnected and trying to open a new connection), failed (permanently failed to connect; e.g., the client and server support different versions of DDP), waiting (failed to connect and waiting to try to reconnect) and offline (user has disconnected the connection).
https://docs.meteor.com/api/connections.html
I'm trying to create a new connection in MongoVUE but I have an error : "Connection was refused".
The connection configuration is:
Name: database
Server: 127.0.0.1
Port: 27017(default)
Username:admin
Connection was refused Unable to connect to server 127.0.0.1:27017:
Object reference not set to an instance of an object.. Type:
MongoDB.Driver.MongoConnectionException Stack: at
MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan
timeout, ReadPreference readPreference) at
MongoDB.Driver.MongoServer.Connect(TimeSpan timeout) at
MongoDB.Driver.MongoServer.Connect() at
MangoUI.MMongo.QSDlL5xzK686iCExThO(Object ) at
MangoUI.MMongo.Open(Boolean mustWrite) at MangoUI.MMongo.Open()
at MangoUI.MConnection.get_IsValid() at
MangoUI.WinConnect.SCOjR9kYRPerNNngykW(Object ) at
MangoUI.WinConnect.btnTest_Click(Object sender, EventArgs e)
Object reference not set to an instance of an object. Type:
System.NullReferenceException Stack: at
MongoDB.Driver.MongoServerInstance.RefreshStateAsSoonAsPossible()
at MongoDB.Driver.Internal.MongoConnection.HandleException(Exception
ex) at
MongoDB.Driver.Internal.MongoConnection.SendMessage(BsonBuffer buffer,
Int32 requestId) at
MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage
message) at
MongoDB.Driver.Operations.CommandOperation`1.Execute(MongoConnection
connection) at
MongoDB.Driver.MongoServerInstance.RunCommandAs[TCommandResult](MongoConnection
connection, String databaseName, IMongoCommand command) at
MongoDB.Driver.MongoServerInstance.Ping(MongoConnection connection)
at MongoDB.Driver.MongoServerInstance.Connect() at
MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan
timeout, ReadPreference readPreference)
How can I fix it and create connection? Help please.
Maybe you have solved this problem.I just provide how I solve for whom come with it later:
check if your mongodb is on.
Open the browser, input the urllocalhost:27017, you should find that the web page have words like"it seems that you attend to connect the mongodb", then go to step 3.
If not go to step 2.
keep your mongodb on. you should add the install directory to the path variable.
Then create a directory to store you db,for example"D:\data\db\".
Then input this commandmongod --dbpath D:\data\db in the console, never close the console if you want to make connection.
Then go step 3.
Use MongoBooster rather than MongVUE. MongoVUE is nolooger update since 2014. However, mongobooster is well and good,support mongodb from 2.2 to 3.2
That is all.
I have MongoDB 3.0.1 installed on Windows 7 Pro 64bit. Everything that I am doing is being done on this server itself, all connections are via 127.0.0.1:27017. And yes, I have applied the MS Hotfix that was recommended to do by MongoDB. Here is my complete config file:
systemLog:
destination: file
path: "C:\\Program Files\\MongoDB\\Server\\3.0\\data\\log\\mongod.log"
logAppend: true
storage:
dbPath: "C:\\Program Files\\MongoDB\\Server\\3.0\\data\\db"
security:
authorization: enabled
I created a superuser like this:
db.createUser({user:"superuser", pwd:"temp",
roles:[ "userAdminAnyDatabase", "readWrite" ] } )
I can log into mongo console like this:
mongo.exe 127.0.0.1:27017/admin -u superuser -p temp --authenticationDatabase admin --verbose
I can then do everthing from mongo console. But when I try to connect an admin UI such as Mongovue or Robomongo, I get connection refused. Mongovue spits out this stack trace:
Connection was refused
Unable to connect to server 127.0.0.1:27017: Object reference not set to an instance of an object..
Type: MongoDB.Driver.MongoConnectionException
Stack: at MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference)
at MongoDB.Driver.MongoServer.Connect(TimeSpan timeout)
at MongoDB.Driver.MongoServer.Connect()
at MangoUI.MMongo.QSDlL5xzK686iCExThO(Object )
at MangoUI.MMongo.Open(Boolean mustWrite)
at MangoUI.MMongo.Open()
at MangoUI.MConnection.get_IsValid()
at MangoUI.WinConnect.SCOjR9kYRPerNNngykW(Object )
at MangoUI.WinConnect.btnTest_Click(Object sender, EventArgs e)
Object reference not set to an instance of an object.
Type: System.NullReferenceException
Stack: at MongoDB.Driver.MongoServerInstance.RefreshStateAsSoonAsPossible()
at MongoDB.Driver.Internal.MongoConnection.HandleException(Exception ex)
at MongoDB.Driver.Internal.MongoConnection.SendMessage(BsonBuffer buffer, Int32 requestId)
at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message)
at MongoDB.Driver.Operations.CommandOperation`1.Execute(MongoConnection connection)
at MongoDB.Driver.MongoServerInstance.RunCommandAs[TCommandResult](MongoConnection connection, String databaseName, IMongoCommand command)
at MongoDB.Driver.MongoServerInstance.Ping(MongoConnection connection)
at MongoDB.Driver.MongoServerInstance.Connect()
at MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpan timeout, ReadPreference readPreference)
This looks like a null pointer to me. Am I missing a config somewhere ? What do I need to do to get this to work ?
Thanks,
Warren
I guess the answer is as simple as Mongovue and Robomongo do not support Mongo DB 3.0.1 yet. I had no problems getting the Mongo console to connect and 3T MongoChef to connect. Now I guess I need to make sure Mongoose is good.