Home > English > Embedded Mongo and Windows Firewall alerts

Embedded Mongo and Windows Firewall alerts

Long time no see :) I’ll start slowly, so that the pace of writing helps me get back to writing.

Finally I had some time to work on code in the project, and found out most annoying thing ever. We’re using MongoDB in production so for couple of integration tests we use embedded Mongo. It’s a simple tool that we are using the same way as HSQL or H2 DB. DB instance is created by tests that need it and after they are done DB is cleaned up automatically. During that short period when instance is available it may be accessed same way as any normal Mongo instance. We have few tests using it, just to prove that our DB layer is working as expected.  The annoyance I’ve mentioned in the beginning, comes when somebody miss-configure it and try to use under Windows with Firewall turned on. Below example of how to start it without mentioned issue.

CustomMongoDBProperties dbConfig = new CustomMongoDBProperties();         
MongodStarter runtime = MongodStarter.getDefaultInstance();
Net netSettings = new Net("127.0.0.1", Network.getFreeServerPort(), Network.localhostIsIPv6());
_mongodExe = runtime.prepare(
	new MongodConfigBuilder().version(Version.Main.PRODUCTION).net(netSettings).build());
_mongod = _mongodExe.start();

Looks simple? And it is, however if you’re going to remove ip address, being first parameter of net constructor “127.0.0.1”, Windows Firewall will raise alarm every time you run those damned tests. Code compiles, tests are green, just FW pops up a lot!

I hope that it will help you to save some nerves. Of course the proper fix is to install Linux, however this one is good enough workaround for me ;)

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: