diff --git a/config/config.yaml b/config/config.yaml index 0385c8831..381c1c6d4 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -8,7 +8,7 @@ etcd: etcdSchema: openim #默认即可 etcdAddr: [ 127.0.0.1:2379 ] #单机部署时,默认即可 userName: - password: + password: k8sMod: false #开启k8s模式 使用pod里面环境变量请求services调用服务 而并非etcd @@ -27,13 +27,14 @@ mysql: mongo: dbUri: ""#当dbUri值不为空则直接使用该值 - dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可 + #dbAddress: 127.0.0.1:37017 #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可 + dbAddress: [ 127.0.0.1:37017 ] #单机时为mongo地址,使用分片集群时,为mongos地址 默认即可 dbDirect: false dbTimeout: 60 dbDatabase: openIM #mongo db 默认即可 dbSource: admin - dbUserName: #mongo用户名,建议先不设置 - dbPassword: #mongo密码,建议先不设置 + dbUserName: openIM #mongo用户名,建议先不设置 + dbPassword: openIM== #mongo密码,建议先不设置 dbMaxPoolSize: 100 dbRetainChatRecords: 3650 #mongo保存离线消息时间(天),根据需求修改 chatRecordsClearTime: "* * * * *" # 每天凌晨3点清除消息,该配置和linux定时任务一样, 清理操作建议设置在用户活跃少的时候 # 0 3 * * * @@ -122,7 +123,7 @@ credential: #腾讯cos,发送图片、视频、文件时需要,请自行申 appBucket: app # 存储app的桶 location: us-east-1 endpoint: http://127.0.0.1:10005 #minio外网ip 这个ip是给客户端访问的 - endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以填写 + endpointInner: http://127.0.0.1:10005 #minio内网地址 如果im server 可以通过内网访问到 minio就可以 endpointInnerEnable: true #是否启用minio内网地址 启用可以让桶初始化,IM server连接minio走内网地址访问 accessKeyID: user12345 secretAccessKey: key12345 diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index aac99a768..3a84c74b3 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -91,7 +91,7 @@ func (ws *WServer) readMsg(conn *UserConn) { log.NewInfo("", "this is a pingMessage") } if err != nil { - log.Error("", "WS ReadMsg error ", " userIP", conn.RemoteAddr().String(), "userUid", "platform", "error", err.Error()) + log.NewWarn("", "WS ReadMsg error ", " userIP", conn.RemoteAddr().String(), "userUid", "platform", "error", err.Error()) userCount-- ws.delUserConn(conn) return diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 62b3eb373..a9b0fd343 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -103,17 +103,17 @@ type config struct { SlowThreshold int `yaml:"slowThreshold"` } Mongo struct { - DBUri string `yaml:"dbUri"` - DBAddress string `yaml:"dbAddress"` - DBDirect bool `yaml:"dbDirect"` - DBTimeout int `yaml:"dbTimeout"` - DBDatabase string `yaml:"dbDatabase"` - DBSource string `yaml:"dbSource"` - DBUserName string `yaml:"dbUserName"` - DBPassword string `yaml:"dbPassword"` - DBMaxPoolSize int `yaml:"dbMaxPoolSize"` - DBRetainChatRecords int `yaml:"dbRetainChatRecords"` - ChatRecordsClearTime string `yaml:"chatRecordsClearTime"` + DBUri string `yaml:"dbUri"` + DBAddress []string `yaml:"dbAddress"` + DBDirect bool `yaml:"dbDirect"` + DBTimeout int `yaml:"dbTimeout"` + DBDatabase string `yaml:"dbDatabase"` + DBSource string `yaml:"dbSource"` + DBUserName string `yaml:"dbUserName"` + DBPassword string `yaml:"dbPassword"` + DBMaxPoolSize int `yaml:"dbMaxPoolSize"` + DBRetainChatRecords int `yaml:"dbRetainChatRecords"` + ChatRecordsClearTime string `yaml:"chatRecordsClearTime"` } Redis struct { DBAddress []string `yaml:"dbAddress"` diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 3642b31c3..aa7a747cf 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -337,4 +337,4 @@ const StatisticsTimeInterval = 60 const MaxNotificationNum = 100 -const CurrentVersion = "v2.3.3" +const CurrentVersion = "v2.3.3-rc0" diff --git a/pkg/common/db/model.go b/pkg/common/db/model.go index 7fe53b77a..c5e2349fe 100644 --- a/pkg/common/db/model.go +++ b/pkg/common/db/model.go @@ -58,15 +58,30 @@ func init() { // example: mongodb://$user:$password@mongo1.mongo:27017,mongo2.mongo:27017,mongo3.mongo:27017/$DBDatabase/?replicaSet=rs0&readPreference=secondary&authSource=admin&maxPoolSize=$DBMaxPoolSize uri = config.Config.Mongo.DBUri } else { + //mongodb://mongodb1.example.com:27317,mongodb2.example.com:27017/?replicaSet=mySet&authSource=authDB + mongodbHosts := "" + for i, v := range config.Config.Mongo.DBAddress { + if i == len(config.Config.Mongo.DBAddress)-1 { + mongodbHosts += v + } else { + mongodbHosts += v + "," + } + } + if config.Config.Mongo.DBPassword != "" && config.Config.Mongo.DBUserName != "" { - uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin", config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, config.Config.Mongo.DBAddress, + // clientOpts := options.Client().ApplyURI("mongodb://localhost:27017,localhost:27018/?replicaSet=replset") + //mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]] + //uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin&replicaSet=replset", + uri = fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%d&authSource=admin", + config.Config.Mongo.DBUserName, config.Config.Mongo.DBPassword, mongodbHosts, config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize) } else { uri = fmt.Sprintf("mongodb://%s/%s/?maxPoolSize=%d&authSource=admin", - config.Config.Mongo.DBAddress, config.Config.Mongo.DBDatabase, + mongodbHosts, config.Config.Mongo.DBDatabase, config.Config.Mongo.DBMaxPoolSize) } } + mongoClient, err := mongo.Connect(context.TODO(), options.Client().ApplyURI(uri)) if err != nil { fmt.Println(" mongo.Connect failed, try ", utils.GetSelfFuncName(), err.Error(), uri)