2014년 12월 4일 목요일

MongoDB EC2 C# Upload Issues - Missing Key?

I asked this question on stack-overflow http://stackoverflow.com/questions/27264499/mongodb-ec2-c-sharp-upload-issues-missing-key, but am posting it here as well. Any help would definitely be appreciated. I'm fairly new to Mongo EC2 deployments.

I'm currently building a C# interface that should ideally upload JSON documents into a MongoDB database stored on an EC2 Server.
So far, I've been able to access the instance of Mongo on the EC2 server using PuTTY and the resulting console line interface, but am unable to do this in C#. Each time I've been getting the same error:
Additional information: Unable to connect to server bitnami@ec2-54-174-43-69.compute-1.amazonaws.com:22: A non-recoverable error occurred during a database lookup.
The code I am using is below (username, password, and database name modified for privacy):
            // Create a metadataObj for upload.
            MetadataTemplate metaUpload = createMetadataObj();

            // Upload to MongoDB
            var connectionString = "mongodb://afhaque:Njmitx123@bitnami@ec2-54-174-43-69.compute-1.amazonaws.com:22/sensoDxDatabase";
            var mongoEC2 = new MongoClient(connectionString);
            var server = mongoEC2.GetServer();
            var database = server.GetDatabase("sensoDxDatabase");
            var collection = database.GetCollection<MetadataTemplate>("sensoahmed");

            // Insert record into DB
            collection.Insert(metaUpload);
I am wondering if what's missing is that I'm not including the AWS Private Key (ppk) that I use in PuTTY. If this is the case, can anyone point me to how I can include this in the Mongo connection? As of now, the MongoClient(connectionString) is my only form of connection to Mongo or EC2. Is there a preliminary connection to the EC2 instance necessary that I'm missing?
Then again, I admit... I may be missing something else completely. All suggestions welcome.





I posted this question on StackOverflow, but am looking for all the help I can get.
I'm currently building a C# interface that should ideally upload JSON documents into a MongoDB database stored on an EC2 Server.
So far, I've been able to access the instance of Mongo on the EC2 server using PuTTY and the resulting console line interface, but am unable to do this in C#. Each time I've been getting the same error:
Additional information: Unable to connect to server bitnami@ec2-54-174-43-69.compute-1.amazonaws.com:22: A non-recoverable error occurred during a database lookup.
The code I am using is below (username, password, and database name modified for privacy):
            // Create a metadataObj for upload.
            MetadataTemplate metaUpload = createMetadataObj();

            // Upload to MongoDB
            var connectionString = "mongodb://afhaque:Njmitx123@bitnami@ec2-54-174-43-69.compute-1.amazonaws.com:22/sensoDxDatabase";
            var mongoEC2 = new MongoClient(connectionString);
            var server = mongoEC2.GetServer();
            var database = server.GetDatabase("sensoDxDatabase");
            var collection = database.GetCollection<MetadataTemplate>("sensoahmed");

            // Insert record into DB
            collection.Insert(metaUpload);
I am wondering if what's missing is that I'm not including the AWS Private Key (ppk) that I use in PuTTY. If this is the case, can anyone point me to how I can include this in the Mongo connection? As of now, the MongoClient(connectionString) is my only form of connection to Mongo or EC2. Is there a preliminary connection to the EC2 instance necessary that I'm missing?
I've also confirmed that my code works when using a localhost DB.
I've also tested this code within an (working) SshClient connection using SSH.Net. But again same error.
...

All suggestions welcome. 


댓글 없음:

댓글 쓰기