     @mongoHost = @config.databases.mongodb[0].host
     @mongoUser = @config.databases.mongodb[0].user
     @mongoPass = @config.databases.mongodb[0].password
-    @server = new mongo.Server @mongoHost, 27017
+    @server = new mongo.Server @mongoHost, 27017, socketOptions:keepAlive:5
 
   uniqueId = (length=8) ->
 

            log.error err if err
            collection.find({},{fields:user:1}).toArray (err,items)->
              log.error err if err
              usernames = []
              for user in items
                usernames.push user.user


    db = new mongo.Db dbConf.dbName, @server

    dbCount = (username,callback) =>
      @fetchDatabaseList username:username,(err,dbsArray)->
        if err then callback err
        else
          callback null,dbsArray.length
  
    dbCount username,(err,dbNr)=>
      unless err
        if dbNr > 20 # 0..4
          log.error e = "You exceeded your quota, please delete one before adding a new one."
          callback new KodingError e
        else
          db.open (err,db)=>
            if err?
              log.error "[ERROR] can't open database #{dbConf.dbName}: #{err}"
              callback? "[ERROR] can't open database #{dbConf.dbName}: #{err}"
            else
              db.admin().authenticate @mongoUser, @mongoPass,(err,result)=>
                if err?
                  log.error "[ERROR] can't authenticate with admin credentials: #{err}"
                  callback?  "[ERROR] can't authenticate with admin credentials: #{err}"
                else
                  db.addUser dbConf.dbUser,dbConf.dbPass,(err,res)->
                    log.debug err,res
                    db.authenticate dbConf.dbUser,dbConf.dbPass,(err,res)->
                      if err?
                        log.error "[ERROR] can't create user #{dbConf.dbUser} and database #{dbConf.dbName}: #{err}"
                        callback? "[ERROR] can't create user #{dbConf.dbUser} and database #{dbConf.dbName}: #{err}"
                      else
                        log.debug res
                        log.info "[OK] user #{dbConf.dbUser} and database #{dbConf.dbName} has been created"
                        log.info dbConf
                        callback? null,dbConf

  changePassword : (options,callback)->

