A timeout occured after 30000ms selecting a server using CompositeServerSelector

前端 未结 9 1736
南方客
南方客 2020-11-27 07:39

I try to deploy my Mongo database in Mongolabs, everything works fine, and I create a new database. Please see my connectionstring.

    public DbHelper()
            


        
9条回答
  •  攒了一身酷
    2020-11-27 08:07

    Same Error Message but not encountered with a MongoLabs deployment.

    I just encountered the same error listed in the title with an Asp.Net Core App. My issue was due to an IOC configuration issue.

    In my IOC container, my wrapped MongoClient instance was configured with a dependency transient lifestyle.

    Per The MongoDb C# Driver:

    It is recommended to store a MongoClient instance in a global place, either as a static variable or in an IoC container with a singleton lifetime.

    I promoted the lifestyle of my object to a singleton and it resolved the issue.

    I am using:

    • .Net Core 2.0
    • Mongo C# Driver version 2.5
    • Castle Windsor for my IOC version 3.3.0

    Please reference the C# Driver Client section: http://mongodb.github.io/mongo-csharp-driver/2.5/reference/driver/connecting/#re-use

提交回复
热议问题