← 返回
安全合规

Matrix Channel Fix

修复 Matrix Channel 常见问题:加密模块安装、token 过期处理、重新登录等。 Use when: Matrix channel 无法正常工作、加密模块报错、token 失效等问题。
修复 Matrix Channel 常见问题:加密模块安装、token 过期处理、重新登录等。 Use when: Matrix channel 无法正常工作、加密模块报错、token 失效等问题。
boms
安全合规 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 811
下载
💾 9
安装
1
版本
#latest

概述

Matrix Channel 修复指南

常见问题

1. 加密模块缺失

症状:

MatrixClientLite Failed to initialize crypto storage, E2EE disabled
Cannot find module '@matrix-org/matrix-sdk-crypto-nodejs'

修复:

cd /usr/local/lib/node_modules/openclaw
pnpm add @matrix-org/matrix-sdk-crypto-nodejs
pnpm rebuild @matrix-org/matrix-sdk-crypto-nodejs
openclaw gateway restart

2. Token 失效 (M_UNKNOWN_TOKEN)

症状:

errcode: 'M_UNKNOWN_TOKEN', error: 'Invalid access token passed.'

修复:

清除旧 token 并重启:

rm -rf ~/.openclaw/matrix/accounts/*
openclaw gateway restart

3. DNS 解析失败 (ENOTFOUND)

症状:

Error: getaddrinfo ENOTFOUND YOUR_HOMESERVER

检查:

host YOUR_HOMESERVER
ping YOUR_HOMESERVER

4. 重新配置 Matrix Channel

完整重置步骤:

  1. 移除旧配置:
  2. openclaw config unset channels.matrix
    
  1. 重新设置配置:
  2. openclaw config set channels.matrix.homeserver "https://YOUR_HOMESERVER:PORT"
    openclaw config set channels.matrix.userId "@YOUR_BOT_USER_ID"
    openclaw config set channels.matrix.password "YOUR_PASSWORD"
    openclaw config set channels.matrix.deviceName "YOUR_DEVICE_NAME"
    openclaw config set channels.matrix.encryption true
    openclaw config set channels.matrix.enabled true
    
  1. 重启 Gateway:
  2. openclaw gateway restart
    

5. 退出所有房间

如果需要让 bot 退出所有房间:

# 获取 access_token
TOKEN=$(curl -s -X POST "https://YOUR_HOMESERVER:PORT/_matrix/client/r0/login" \
  -H "Content-Type: application/json" \
  -d '{"type":"m.login.password","user":"YOUR_BOT_USER","password":"YOUR_PASSWORD"}' | \
  jq -r '.access_token')

# 获取房间列表
curl -s -X GET "https://YOUR_HOMESERVER:PORT/_matrix/client/r0/joined_rooms" \
  -H "Authorization: Bearer $TOKEN" | jq '.'

# 逐一退出
for room in "ROOM_ID_1" "ROOM_ID_2"; do
  curl -s -X POST "https://YOUR_HOMESERVER:PORT/_matrix/client/r0/rooms/$room/leave" \
    -H "Authorization: Bearer $TOKEN"
done

6. 检查状态

openclaw channels status --probe
openclaw logs | grep -i matrix

诊断命令

命令用途
------------
openclaw status查看整体状态
openclaw channels status查看渠道状态
openclaw channels status --probe探测渠道连通性
`openclaw logs 2>&1 \grep -i matrix`查看 Matrix 日志

配置示例

{
  "channels": {
    "matrix": {
      "enabled": true,
      "homeserver": "https://YOUR_HOMESERVER:PORT",
      "userId": "@YOUR_BOT_USER_ID",
      "password": "YOUR_PASSWORD",
      "deviceName": "YOUR_DEVICE_NAME",
      "encryption": true
    }
  }
}

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 18:42 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,212 📥 266,313
security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,709
security-compliance

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,142