Getting HttpListenerException running in memory with no HTTP server

1,422 views
Skip to first unread message

Sean Kearon

unread,
May 13, 2012, 2:25:15 PM5/13/12
to rav...@googlegroups.com
I had a problem with some of my tests that resulted in registering my store twice.  I'm using the store like this:

  new EmbeddableDocumentStore {RunInMemory = true, UseEmbeddedHttpServer = false}

As I was registering the store twice, I was getting a System.Net.HttpListenerException: "Failed to listen on prefix 'http://+:8080/' because it conflicts with an existing registration on the machine."

Should the HTTP listener be involved at all seeing as this is fully embedded with the HTTP server off?  

Oren Eini (Ayende Rahien)

unread,
May 14, 2012, 9:44:00 AM5/14/12
to rav...@googlegroups.com
It should not, can you provide me with the full stack trace?

Sean Kearon

unread,
May 14, 2012, 1:09:28 PM5/14/12
to rav...@googlegroups.com
SetUp : Autofac.Core.DependencyResolutionException : An exception was thrown while executing a resolve operation. See the InnerException for details.
----> System.Net.HttpListenerException : Failed to listen on prefix 'http://+:8080/' because it conflicts with an existing registration on the machine.

at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.Resolve(IComponentContext context, IEnumerable`1 parameters)
at Atlantic.Test.Common.InMemoryFixture.SetUp() in InMemoryFixture.cs: line 37
at Pirform.Domain.Fixture.tree_changed.Setup() in tree_changed.cs: line 25
--HttpListenerException
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at Raven.Database.Server.HttpServer.StartListening() in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs: line 208
at Raven.Client.Embedded.EmbeddableDocumentStore.InitializeInternal() in c:\Builds\RavenDB-Stable\Raven.Client.Embedded\EmbeddableDocumentStore.cs: line 148
at Raven.Client.Document.DocumentStore.Initialize() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\DocumentStore.cs: line 392
at MyApp.Raven.EmbeddableDocumentStoreInitialiser.Initialise(DocumentStore documentStore) in EmbeddableDocumentStoreInitialiser.cs: line 77
at Atlantic.Test.Common.InMemoryFixture.<SetUp>b__1(IComponentContext x) in InMemoryFixture.cs: line 41
at Autofac.Builder.RegistrationBuilder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p)
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters

Oren Eini (Ayende Rahien)

unread,
May 14, 2012, 5:17:19 PM5/14/12
to rav...@googlegroups.com
This code works:

using(var d1 = new EmbeddableDocumentStore
{
RunInMemory = true,
UseEmbeddedHttpServer = false
}.Initialize())
using (var d2 = new EmbeddableDocumentStore
{
RunInMemory = true,
UseEmbeddedHttpServer = false
}.Initialize())
{

Sean Kearon

unread,
May 15, 2012, 3:59:12 AM5/15/12
to rav...@googlegroups.com
Bad me - I have a configuration class that was turning the embedded http server back on!  

I'm sure there's an emoticon for embarrased...

Justin A

unread,
May 16, 2012, 2:45:30 AM5/16/12
to rav...@googlegroups.com
Actually Sean, lets go even better :






tehehehehehehehehehehehehe

Sean Kearon

unread,
May 16, 2012, 3:26:30 AM5/16/12
to rav...@googlegroups.com
Lol - yeah, that about sums it up :)
Reply all
Reply to author
Forward
0 new messages