克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

JuggleIM

一个高性能,可扩展的开源 IM 即时通讯系统。

  • 官网: https://www.juggle.im
  • 提问: https://github.com/juggleim/im-server/issues
  • 文档: https://www.juggle.im/docs/guide/intro/

社群讨论

如果对 IM 感兴趣、有集成问题讨论的朋友,非常欢迎加入社群讨论~

Telegram 中文群Telegram English添加好友加入微信群

备注:由于微信群二维码有时间限制,加入微信讨论可优先加 小山 微信好友,由 Ta 邀请进群组

特性

  • 灵活的部署模式,支持公有云,私有云,托管云等部署形态。
  • Protobuf+Websocket 实现长连接,低流量,高性能,且在网络不佳的环境下具备较好的连通性。
  • 性能强大,专业版支持集群部署,无限横向扩展,能支撑亿级日活应用。
  • 协议及数据全链路加密,无数据泄露风险。
  • 提供方便的运维工具和管理后台,简单好维护。
  • 支持Android,iOS,Web,PC 等多平台 SDK,提供快捷集成的Demo和文档。
  • 支持多端同时在线和消息多端同步,确保状态多端一致。
  • 支持全球链路加速,可服务全球级应用。
  • 提供丰富的API和WebHook,可方便的与现有系统集成。
  • 支持万人,十万人大群,轻松沟通,不丢消息。
  • 支持无上限直播聊天室。
  • 具备 AI 机器人对接能力,可轻松对接大模型。

快速部署体验

部署文档(https://www.juggle.im/docs/guide/quickdeploy/)

手动部署

1. 安装并初始化 MySQL

1) 安装 MySQL

2) 创建DB实例

CREATE SCHEMA `jim_db` ;

3) 初始化表结构

初始化表结构的sql文件在 im-server/docs/jim.sql , 导入命令如下:

mysql -u{db_user} -p{db_password} jim_db < jim.sql

2. 安装MongoDB(可选)

3. 启动im-server

1) 运行目录

运行目录为 im-server/launcher,其中 conf 目录下存放的是配置文件,logs目录下是服务的运行日志目录。

2) 编辑配置文件

配置文件位置:im-server/launcher/conf/config.yml

nodeName: testNode      # im-server 的节点名称
nodeHost: 127.0.0.1     # im-server 的节点IP
msgStoreEngine: mysql   # 配置用什么存储来存消息数据,有两种存储引擎可选。mysql:使用mysql存储消息数据(默认);mongo:使用MongoDB存储消息数据

log:
  logPath: ./logs       # 运行日志所在目录
  logName: jim-info     # 运行日志的前缀名
  visual: false         # 是否开启可视化日志。开启后,会同步将日志数据写入一个 KV 数据库,在管理后台”开发工具->连接排查“处,可界面化查询日志;

mysql:                  # im-server 所用的MySQL相关配置
  user: root
  password: 123456
  address: 127.0.0.1:3306
  name: im_db

mongodb:                # im-server 所用的MongoDB相关配置,用于存储消息数据。该配置为可选,在 msgStoreEngine 配置为 "mongo" 时生效;
  address: 127.0.0.1:27017
  name: jim_msgs        # mongodb 表空间名称,im-server启动后,会自动在这个空间下初始化collection;

connectManager:         # im-server 长连接端口
  wsPort: 9002

apiGateway:             # im-server 的服务端 API 端口, 供业务APP的服务端调用;
  httpPort: 8082

navGateway:             # im-server 的导航端口,客户端SDK初始化时,需要到导航地址;
  httpPort: 8081

adminGateway:           # im-server 自带的管理后台地址,默认账号密码是:admin/123456
  httpPort: 8090

3) 启动im-server

在 im-server/launcher 目录下,执行如下命令:

go run main.go

4) 配置外网访问地址(域名/IP)

需要配置外网地址的端口列表:

端口 协议类型 说明
8081 http 导航服务的监听端口,用于客户端 SDK,SDK 初始化时需要传入这个地址;
8082 http 服务端 API 服务监听端口,用于业务服务器,例如 jugglechat-server 配置文件中需要配置这个地址;
8090 http IM 服务的管理后台监听端口,默认账号和密码:admin/123456
9002 websocket IM 长连接监听端口,用于客户端SDK与IM 服务建立长连接(websocket)

配置外网地址的方法,这里不详细描述,大家可以根据自身环境来灵活配置(常用方式: 挂公网ip,nginx反向代理,负载均衡等).

注: 如果仅内网调试使用,可以不配置外网IP/域名,仅使用内网IP即可

5) 将长连接地址配置到IM系统中

配置方式很简单,在数据库中插入一条配置数据即可:

insert into globalconfs (conf_key, conf_value)values('connect_address', '{"default":["127.0.0.1:9002"]}')

其中,将 127.0.0.1 替换成该机器的内网IP,或对外的公网IP/域名,这个是客户端SDK的长连接地址,将有导航服务(8081)下发给客户端SDK;

4. 创建应用(租户)

JuggleIM 本身是一套多租户的系统,可以在一套服务中创建多个appkey(租户),租户之间的数据相互隔离,互不影响。

方式一:登录管理后台,创建租户

待完善

方式二:通过管理API,创建租户

其中,app_key 用于指定租户的标识,可自定义,要求在系统内唯一;app_name为租户的名称,可自定义; 注:这里用的是IM服务管理后台(8090)的地址,127.0.0.1 替换成im服务的内网IP,或公网IP/域名。

curl --request POST \
  --url http://127.0.0.1:8090/admingateway/apps/create \
  --data '{
    "app_key":"appkey",
    "app_name":"appname"
}'

响应数据示例:

{
	"code": 0,
	"msg": "success",
	"data": {
		"app_name": "appname",
		"app_key": "appkey",
		"app_secret": "hciKcc6sXRDjYUQp"
	}
}

5. 登入管理后台

管理后台地址:http://127.0.0.1:8090 默认账号/密码: admin/123456

登入管理后台后,即可看到创建的应用列表,点击其中一个应用,可以对其配置进行修改和维护。

6. 业务服务器/客户端集成

这里汇总下业务集成所需的各项配置:

  1. 业务服务器集成
配置项 示例 备注
IM 服务端 API 地址 http://127.0.0.1:8082 供业务服务器访问IM服务的API接口地址,使用该接口可以注册IM用户,创建群,发送系统消息等,接口文档参考:https://www.juggle.im/docs/server/api/
app_key appkey1 应用的租户标识,在第4步中创建,可自定义,但要保证在系统内唯一
app_secret hciKcc6sXRDjYUQp 应用对应的鉴权秘钥,创建应用时自动生成。如果想自定义的话,确保配置为16位的字符串。注意:确保该秘钥仅在业务服务器端使用,不要泄露到客户端。
  1. 客户端SDK集成
配置项 示例 备注
IM 服务的导航地址 http://127.0.0.1:8081 客户端SDK初始化时需要传入,参考文档:https://www.juggle.im/docs/client/quickstart/android/
IM 服务的长连接地址 ws://127.0.0.1:9002 IM 的长连接地址,不需要配置到客户端,将有导航服务负责下发到SDK
app_key appkey1 应用的租户标识,确保与业务服务器端配置的保持一致。
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

A high-performance IM server 展开 收起
Go 等 4 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化