2

From a Winforms application using the same connection code, RavenDB works fine. I'm able to store and retrieve documents with abandon.

When I try to do the same thing in a Nancy application the result is completely unexpected.

Nancy is listening on port 12345, and RavenDB is running in Embedded mode with UseEmbeddedHttpServer enabled and listening on port 8080.

The very first request to http://localhost:12345/ gets a web page response as requested. Any subsequent request to http://localhost:12345/ is redirected to /raven/studio.html. If the first request I make is to /widgets Nancy returns a JSON list of widgets as expected, but any subsequent request returns:

Could not figure out what to do

Your request didn't match anything that Raven knows to do, sorry...

It seems like RavenDB is hijacking the port Nancy is listening on. Any ideas what would cause this behaviour?

nathanchere
  • 8,008
  • 15
  • 65
  • 86
  • Don't want to mark as duplicate, but it sounds like the same thing described [here](http://stackoverflow.com/q/13147077/634824), in which case the answer was incorrect port settings. Are you *sure* that RavenDB is on 8080? Can you please update with your init code and/or settings? Also, please confirm what version of RavenDB you are using. Thanks. – Matt Johnson-Pint May 31 '13 at 00:29
  • When running the Winforms client, yes. When running the Nancy client, no. It takes over port 12345 after the first Nancy request which instantiates the RavenDB document store. – nathanchere May 31 '13 at 00:39
  • and using Raven build 2360. – nathanchere May 31 '13 at 00:40

2 Answers2

7

When hosted by IIS, the port for RavenDB needs to be set explicitly.

The default value is coming from IIS config, which is why it isn't an issue when running embedded mode from a Winforms application.

(db as EmbeddableDocumentStore).Configuration.Port = 8080;

nathanchere
  • 8,008
  • 15
  • 65
  • 86
4

There's no good reason I can think of that it would do that.

Perhaps you should specify an explicit Raven/Port setting. See these docs.

Or you can do it programatically:

var store = new EmbeddableDocumentStore {UseEmbeddedHttpServer = true};
store.Configuration.Port = 8080;
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575