Help with error

393 views
Skip to first unread message

PRinCE Dinson

unread,
Feb 23, 2012, 7:35:12 AM2/23/12
to mongodb-user
I am trying to insert, update, delete and retrieve data from mongodb
using VS2010, and C# Driver 1.3.1


Here is the C# code (not the whole code file, only the relevant part)
i use:

**************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Bson.IO;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Conventions;
using MongoDB.Bson.Serialization.IdGenerators;
using MongoDB.Bson.Serialization.Options;
using MongoDB.Bson.Serialization.Serializers;
using MongoDB.Driver.Builders;
using MongoDB.Driver.GridFS;
using MongoDB.Driver.Wrappers;
********************************
-
-
-
string connectionString = "mongodb://localhost"; // Declared
outside the function
//
so that available throughout
//
the whole class for each
//
4 functions namely
//
Insert(), Update(), Delete()
//
and Display()
-
-
-
public int Insert(BO.Data data) // One
of the functions
{
MongoServer server = MongoServer.Create(connectionString);
try
{
MongoDatabase myMongoDB =
server.GetDatabase("myMongoDB");

//
On First run, the database
//
myMongoDB doesn't exist
//
and has to be created. MongoDB
//
does this automatically, i think.
//
Next run onwards, just select
//
this database.

MongoCollection<BO.Data> myData =
myMongoDB.GetCollection<BO.Data>("myData");

//
On First run, the collection
//
myData doesn't exist
//
and has to be created. MongoDB
//
does this automatically, i think.
//
Next run onwards, just select
//
this collection.
BO.Data newData = new BO.Data(); //Object of
class Data. has members
//
string, int and System.Drawing.Bitmap
newData.FirstName = data.FirstName;
newData.LastName = data.LastName;
newData.Pic = new Bitmap(data.Pic);
newData.PersonID = data.PersonID;
newData.Age = data.Age;

myData.Insert(newData); // Insert the
Data into myData
return (1);
}
catch
{
throw;
}
finally
{
server.Disconnect();
}

}
-
-
-

It cannot even get into the try loop coz some error is happening, and
it goes to the catch-finally part.

I thought maybe some thing wrong with the server connection, so i ran
mongod.exe from a CMD console. I got this error:

************************************************************************************
mongod.exe --help for help and startup options
Thu Feb 23 17:34:44
Thu Feb 23 17:34:44 warning: 32-bit servers don't have journaling
enabled by default. Please use --journal if you want durability.
Thu Feb 23 17:34:44
Thu Feb 23 17:34:45 [initandlisten] MongoDB starting : pid=2528
port=27017 dbpath=/data/db 32-bit host=prasadcg
Thu Feb 23 17:34:45 [initandlisten]
Thu Feb 23 17:34:45 [initandlisten] ** NOTE: when using MongoDB 32
bit, you are limited to about 2 gigabytes of data
Thu Feb 23 17:34:45 [initandlisten] ** see
http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Feb 23 17:34:45 [initandlisten] ** with --journal, the limit
is lower
Thu Feb 23 17:34:45 [initandlisten]
Thu Feb 23 17:34:45 [initandlisten] db version v2.0.2, pdfile version
4.5
Thu Feb 23 17:34:45 [initandlisten] git version:
514b122d308928517f5841888ceaa4246a7f18e3
Thu Feb 23 17:34:45 [initandlisten] build info: windows (5, 1, 2600,
2, 'Service Pack 3') BOOST_LIB_VERSION=1_42
Thu Feb 23 17:34:45 [initandlisten] options: {}
Thu Feb 23 17:34:45 [initandlisten] ERROR: listen(): bind() failed
errno:10048 Only one usage of each socket address (protocol/network
address/port) is normally permitted. for socket: 0.0.0.0:27017
Thu Feb 23 17:34:45 [initandlisten] now exiting
Thu Feb 23 17:34:45 dbexit:
Thu Feb 23 17:34:45 [initandlisten] shutdown: going to close listening
sockets...
Thu Feb 23 17:34:45 [initandlisten] shutdown: going to flush
diaglog...
Thu Feb 23 17:34:45 [initandlisten] shutdown: going to close
sockets...
Thu Feb 23 17:34:45 [initandlisten] shutdown: waiting for fs
preallocator...
Thu Feb 23 17:34:45 [initandlisten] shutdown: closing all files...
Thu Feb 23 17:34:45 [initandlisten] closeAllFiles() finished
Thu Feb 23 17:34:45 [initandlisten] shutdown: removing fs lock...
Thu Feb 23 17:34:45 [websvr] ERROR: listen(): bind() failed errno:
10048 Only one usage of each socket address (protocol/network address/
port) is normally permitted. for socket: 0.0.0.0:28017
Thu Feb 23 17:34:45 dbexit: really exiting now
*********************************************************************************************


I used taskmanager to see whether there was much network load, but it
doesnot show anything as such...

netstat -n gives this output
*****************************

Active Connections

Proto Local Address Foreign Address State
TCP 127.0.0.1:1043 127.0.0.1:1044 ESTABLISHED
TCP 127.0.0.1:1044 127.0.0.1:1043 ESTABLISHED
TCP 127.0.0.1:1047 127.0.0.1:1048 ESTABLISHED
TCP 127.0.0.1:1048 127.0.0.1:1047 ESTABLISHED

****************************************

Have installed mongos.exe as a service.
started it using :
net start mongos

then netstat-n gives this:

************************************************

Active Connections

Proto Local Address Foreign Address State
TCP 127.0.0.1:1043 127.0.0.1:1044 ESTABLISHED
TCP 127.0.0.1:1044 127.0.0.1:1043 ESTABLISHED
TCP 127.0.0.1:1047 127.0.0.1:1048 ESTABLISHED
TCP 127.0.0.1:1048 127.0.0.1:1047 ESTABLISHED
TCP 127.0.0.1:4810 127.0.0.1:12080 ESTABLISHED
TCP 127.0.0.1:4812 127.0.0.1:12080 ESTABLISHED
TCP 127.0.0.1:4814 127.0.0.1:12080 ESTABLISHED
TCP 127.0.0.1:4816 127.0.0.1:12080 ESTABLISHED
TCP 127.0.0.1:12080 127.0.0.1:4810 ESTABLISHED
TCP 127.0.0.1:12080 127.0.0.1:4812 ESTABLISHED
TCP 127.0.0.1:12080 127.0.0.1:4814 ESTABLISHED
TCP 127.0.0.1:12080 127.0.0.1:4816 ESTABLISHED
TCP 192.168.1.235:4811 68.232.44.119:80 CLOSE_WAIT
TCP 192.168.1.235:4813 68.232.44.119:80 CLOSE_WAIT
TCP 192.168.1.235:4815 122.178.225.34:80 ESTABLISHED
TCP 192.168.1.235:4817 122.178.225.34:80 ESTABLISHED
*******************************************************************

I dont see anything regarding 0.0.0.0:27017 here... please help

Windows Firewall is off. No 3rd party firewall or AV running.
OS is XP pro, version 2002, service pack 3
Visual Studio 2010 (no sp installed right now, but will update in a
day or 2 to SP1).
MongoDB downloaded on 23Feb 2012 (the then latest stable version) and
the c# Driver is the officially supported one, version 1.3.1

Nat

unread,
Feb 23, 2012, 8:28:34 AM2/23/12
to mongod...@googlegroups.com
If you don't specify parameter, mongod will start on port 27017 same as mongos. If you don't plan to try out sharding, you should probably only start up mongod.

Note that to view listened ports, you should use netstat -na to view all sockets.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Reply all
Reply to author
Forward
0 new messages