You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSO2 APIM 4.1.0发布新API后调用报404,重启恢复求解决方案

WSO2 APIM 4.1.0 发布API后调用404(重启后恢复)问题排查与解决

问题描述

在WSO2 APIM 4.1.0单节点部署环境中,发布新API后状态显示为Published,但订阅后通过Postman调用返回404错误,Carbon日志提示“API not found”。已尝试以下操作但问题未解决:

  • 删除应用并重新发布API
  • 复制原有应用信息新增API

重启WSO2 APIM服务后,API可正常调用,无404错误。

环境核心配置

[server]
hostname = "***.****.****.****"
base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}"
server_role = "default"

[[apim.gateway.environment]]
name = "Default"
type = "hybrid"
http_endpoint = "http://***.****.****.****:${http.nio.port}"
https_endpoint = "https://***.****.****.****:${https.nio.port}"

[apim.sync_runtime_artifacts.gateway]
gateway_labels =["Default"]

# 数据库、监听器等完整配置见原提问

可能的原因及解决方案

1. 手动触发网关同步

发布API后网关未自动同步最新定义,重启服务时会触发全量同步因此恢复正常。无需重启,手动触发同步即可:

  • 登录APIM管理控制台,进入 Main > API Management > Gateway > Gateway Artifacts
  • 选择Default网关环境,点击Sync Artifacts按钮执行全量同步

2. 确认自动同步配置

检查deployment.toml是否开启自动同步,若未配置需添加:

[apim.sync_runtime_artifacts.gateway]
gateway_labels = ["Default"]
enable_auto_sync = true  # 默认可能开启,若被注释需解除

添加后重启一次服务,后续发布API会自动同步到网关,避免重复触发手动操作。

3. 排查同步日志

查看wso2carbon.log中含GatewayArtifactSyncer的日志,确认同步过程是否有错误:

  • 搜索关键词:GatewayArtifactSyncer、syncing artifacts、failed to sync
  • 若存在数据库连接超时、权限不足等错误,需对应修复数据库配置或权限

4. 清理网关缓存

网关缓存未及时更新也会导致404,可手动清理缓存:

  • 停止APIM服务,删除<APIM_HOME>/repository/deployment/server/synapse-configs/default/api目录下的所有API文件
  • 启动服务或触发同步,网关会重新拉取最新API定义

5. 检查事件监听器影响

原配置中的token_revocation事件监听器若异常,可能阻断API发布后的通知流程,可暂时注释该监听器测试:

# [[event_listener]]
# id = "token_revocation"
# type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler"
# name = "org.wso2.is.notification.ApimOauthEventInterceptor"
# order = 1
# [event_listener.properties]
# notification_endpoint = "https://***.****.****.****:${mgt.transport.https.port}/internal/data/v1/notify"
# username = "${admin.username}"
# password = "${admin.password}"
# 'header.X-WSO2-KEY-MANAGER' = "default"

测试发布API是否正常,若恢复则需排查该监听器的配置或后端服务状态。


内容的提问来源于stack exchange,提问作者Tony

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 03:27:39