【问题标题】:Getting System.Net.Sockets.SocketException while accessing RavenDB访问 RavenDB 时获取 System.Net.Sockets.SocketException
【发布时间】:2012-06-24 12:58:32
【问题描述】:

最近我通过NuGet 包管理器安装了RavenDB(一堆程序集:客户端、数据库、嵌入式)。我已经像这样配置了DocumentStore

public override void Load()
{
    Bind<IDocumentStore>().ToMethod(
        context => {
            var documentStore = new EmbeddableDocumentStore { 
                Url = "http://localhost:8080", 
                DefaultDatabase = "ampDatabase",
                UseEmbeddedHttpServer = true
            };
            return documentStore.Initialize();
        }
    ).InSingletonScope();

    Bind<IDocumentSession>().ToMethod(context => 
        context.Kernel.Get<IDocumentStore>().OpenSession()
    ).InRequestScope();
}

调用此代码后:

documentSession.Store(idea);
documentSession.SaveChanges();

我收到System.Net.Sockets.SocketException:

无法建立连接,因为 目标机器主动拒绝 127.0.0.1:8080

我错过了什么?

【问题讨论】:

    标签: asp.net-mvc exception ravendb


    【解决方案1】:

    你是这样设置的:

     var documentStore = new EmbeddableDocumentStore { 
                    Url = "http://localhost:8080", 
                    DefaultDatabase = "ampDatabase",
                    UseEmbeddedHttpServer = true
                };
    

    问题在于,这实际上告诉我们不要使用嵌入式模式,而是尝试以服务器客户端方式进行操作。 将其更改为:

     var documentStore = new EmbeddableDocumentStore { 
                    DataDirectory = "Database",
                    UseEmbeddedHttpServer = true
                };
    

    它会起作用的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多