Files
JoyD/Claw/scripts/validate_wecom_callback.bat
2026-03-16 15:47:55 +08:00

116 lines
3.5 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
echo 🔍 验证企业微信回调配置...
echo 📅 验证时间: %date% %time%
echo 📋 配置信息:
echo 回调URL: https://pactgo.cn/wecom
echo 代理目标: http://127.0.0.1:8000/api/v1/wechat/callback
echo 配置文件: d:\Projects\trunk\JoyD\Claw\docs\nginx.conf
REM 检查Nginx配置语法
echo 🔍 检查Nginx配置语法...
nginx -t
if %errorlevel% neq 0 (
echo ❌ Nginx配置语法检查失败
pause
exit /b 1
)
echo ✅ Nginx配置语法正确
REM 检查SSL证书文件
echo 🔍 检查SSL证书文件...
if exist "C:\nginx\ssl\pactgo.cn-chain.pem" (
echo ✅ SSL证书链文件存在
) else (
echo ⚠️ SSL证书链文件不存在: C:\nginx\ssl\pactgo.cn-chain.pem
)
if exist "C:\nginx\ssl\pactgo.cn-key.pem" (
echo ✅ SSL私钥文件存在
) else (
echo ⚠️ SSL私钥文件不存在: C:\nginx\ssl\pactgo.cn-key.pem
)
REM 测试回调URL可达性
echo 🔍 测试回调URL可达性...
echo 📡 测试HTTP到HTTPS重定向...
curl -I http://pactgo.cn/wecom 2>nul | findstr "301" >nul
if %errorlevel%==0 (
echo ✅ HTTP到HTTPS重定向正常
) else (
echo ⚠️ HTTP到HTTPS重定向可能有问题
)
echo 📡 测试HTTPS回调地址...
curl -I -k https://pactgo.cn/wecom 2>nul | findstr "HTTP/" > temp_status.txt
if exist temp_status.txt (
echo ✅ HTTPS回调地址响应:
type temp_status.txt
del temp_status.txt
) else (
echo ⚠️ 无法连接到HTTPS回调地址
)
REM 检查网关服务是否运行
echo 🔍 检查网关服务状态...
curl -s -o nul -w "%%{http_code}" http://127.0.0.1:8000/api/v1/health > temp_gateway_status.txt
set /p GATEWAY_STATUS=<temp_gateway_status.txt
del temp_gateway_status.txt
if "%GATEWAY_STATUS%"=="200" (
echo ✅ 网关服务运行正常 (状态码: %GATEWAY_STATUS%)
) else (
echo ⚠️ 网关服务可能未运行或异常 (状态码: %GATEWAY_STATUS%)
echo 🔧 请确保网关服务已启动并监听在 127.0.0.1:8000
)
REM 测试完整的回调路径
echo 🔍 测试完整回调路径...
echo 📡 测试企业微信回调模拟请求...
curl -X POST -k https://pactgo.cn/wecom \
-H "Content-Type: application/json" \
-d "{\"msg\":\"test\",\"timestamp\":1234567890}" \
-s -o temp_response.txt -w "%%{http_code}" > temp_callback_status.txt
set /p CALLBACK_STATUS=<temp_callback_status.txt
echo 📊 回调响应状态码: %CALLBACK_STATUS%
if exist temp_response.txt (
echo 📄 响应内容:
type temp_response.txt
del temp_response.txt
)
del temp_callback_status.txt
REM 检查Nginx是否运行
echo 🔍 检查Nginx运行状态...
tasklist /FI "IMAGENAME eq nginx.exe" 2>nul | find "nginx.exe" >nul
if %errorlevel%==0 (
echo ✅ Nginx正在运行
) else (
echo ⚠️ Nginx未运行请启动Nginx服务
)
echo.
echo 🎯 企业微信配置建议:
echo 1. 在企业微信管理后台设置回调URL为: https://pactgo.cn/wecom
echo 2. 确保Token和EncodingAESKey与网关服务配置一致
echo 3. 测试消息推送功能
echo 4. 监控回调日志和响应时间
echo.
echo 📊 验证总结:
echo - Nginx配置语法: ✅ 正确
echo - 网关服务状态: %GATEWAY_STATUS% (期望: 200)
echo - SSL证书: 见上方检查结果
echo - 回调URL: 见上方HTTP响应测试
echo.
echo 🚀 下一步:
echo 1. 如果所有检查都通过,可以在企业微信后台配置回调
echo 2. 配置Token和EncodingAESKey
echo 3. 测试实际的消息推送
echo 4. 监控服务日志确保正常工作
echo.
echo 📅 验证完成时间: %date% %time%
pause