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

首次使用ReadyAPI测试API时遭遇502 Proxy Error如何解决?

问题描述

首次使用ReadyAPI测试API,创建简单测试用例后运行出现异常:

  1. 响应返回如下HTML内容:
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<BODY>
<TABLE><TR><TD id=L_dt_1><B>Network Access Message: The page cannot be displayed<B></TR></TABLE>
<TABLE><TR><TD height=15></TD></TR></TABLE>
<TABLE>
<TR><TD id=L_dt_2>Technical Information (for Support personnel)
<UL>
<LI id=L_dt_3>Error Code: 502 Proxy Error. The specified Secure Sockets Layer (SSL) port is not allowed. Forefront TMG is not configured to allow SSL requests from this port. Most Web browsers use port 443 for SSL requests. (12204)
<LI id=L_dt_4>IP Address: 192.168.X.X
<LI id=L_dt_5>Date: 5/13/2023 6:38:14 AM [GMT]
<LI id=L_dt_6>Server: myCompanyServer
<LI id=L_dt_7>Source: proxy
</UL></TD></TR></TABLE></BODY></HTML>
  1. 断言面板提示错误:readyapi open quote is expected for attribute http-equiv associated with an element type meta
  2. 已尝试在ReadyAPI.vmoptions文件末尾添加-Dsoapui.https.protocols=TLSv1,TLSv1.1,TLSv1.2,但问题未解决
解决方案

一、解决502 Proxy Error(SSL端口不允许)

  • 确认API端口合规性:若目标API使用非默认443的SSL端口,需联系运维团队调整Forefront TMG代理规则,将该端口加入允许的SSL请求端口列表。
  • 检查ReadyAPI代理配置:
    1. 打开ReadyAPI,进入File > Preferences > Proxy Settings
    2. 核对代理服务器地址、端口是否正确,确认SSL代理已启用(若公司要求)
    3. 若代理需认证,填写对应用户名和密码
  • 配置代理例外:若测试的API为内部地址,在No Proxy for列表中添加该API的域名或IP,绕过代理直接访问

二、解决断言的HTML格式错误

断言报错源于返回的HTML不符合标准语法(http-equiv属性值未加引号),可通过以下方式调整:

  • 改用文本匹配断言:放弃XML/HTML结构断言,直接匹配响应文本中的关键内容,比如502 Proxy Error或SSL port is not allowed
  • 使用自定义Groovy脚本断言:忽略HTML语法错误,直接校验响应内容,示例脚本:
def response = context.response
assert response.contains("502 Proxy Error") : "未返回预期的502代理错误"
assert response.contains("SSL port is not allowed") : "未返回SSL端口不允许的提示"
  • 关闭HTML语法校验:若必须使用HTML断言,可在对应断言的配置选项中关闭严格语法校验(部分ReadyAPI版本支持该设置)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 01:05:22