在阿里云OpenAPI开启sdk代理之后报错,怎么解决?
Protocol: https
Port: null
POST /
Query:
Url: https://uat-oss.huarunbao.com/emall-dev-open/rest/banner/6a3e5b3e4860ba897dd5209acc735ffb/ED0E2B3D830F43369420B31FFFBBF478.png
Headers:
Authorization: ACS3-HMAC-SHA256 Credential=LTAI5t8zFbSYpQvQsgW68tav,SignedHeaders=host;x-acs-action;x-acs-content-sha256;x-acs-date;x-acs-signature-nonce;x-acs-version,Signature=f085108f840bc93e8401cd3ba5772ecc00b7426fa7edc90ac4f6be68eb677997
x-acs-action: RecognizeVehicleLicense
host: ocr-api.cn-hangzhou.aliyuncs.com
x-acs-date: 2023-12-08T09:22:53Z
x-acs-version: 2021-07-07
x-acs-content-sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-acs-signature-nonce: da91430b0e97aa1bd473f8648d7c7b11
user-agent: AlibabaCloud (Windows 10; amd64) Java/1.8.0_172-b11 tea-util/0.2.21 TeaDSL/1
accept: application/json
protected String doUrlRequest(String requestStr, Request request) throws Exception {
String response = null;
try {
Client client = createClient(accessKeyId,accessKeySecret,serverUrl);
RecognizeVehicleLicenseRequest recognizeVehicleLicenseRequest =
new RecognizeVehicleLicenseRequest();
if(StringUtils.isNotEmpty(request.getTpdParams().get(ServiceCallParamKeys.IMAGE))){
Base64.Decoder decoder = Base64.getDecoder();
byte[] imageByte = decoder.decode(request.getTpdParams().get(ServiceCallParamKeys.IMAGE).split(",")[1]);
InputStream stream = new ByteArrayInputStream(imageByte);
recognizeVehicleLicenseRequest.setBody(stream);
}
if(StringUtils.isNotEmpty(request.getTpdParams().get(ServiceCallParamKeys.IMAGE_URL))){
recognizeVehicleLicenseRequest.setUrl(request.getTpdParams().get(ServiceCallParamKeys.IMAGE_URL));
}
RuntimeOptions runtime = new RuntimeOptions();
RecognizeVehicleLicenseResponse recognizeVehicleLicenseResponse = client.recognizeVehicleLicenseWithOptions(recognizeVehicleLicenseRequest, runtime);
return JSONObject.toJSONString(recognizeVehicleLicenseResponse);
} catch (Exception e) {
log.error("调用阿里云-行驶证信息查询查询异常", e);
return e.getMessage();
}
}
/**
根据您提供的代码和错误信息,问题可能出在阿里云OpenAPI的SDK代理设置上。请尝试以下解决方案:
确保您的httpProxySwitch
变量设置为ON
,并且httpProxyHost
和httpProxyPort
变量已经正确设置为您的代理服务器地址和端口。
检查您的网络连接是否正常,确保您可以访问阿里云OpenAPI的接口。
如果问题仍然存在,您可以尝试使用其他HTTP客户端库(如Apache HttpClient或OkHttp)替换阿里云OpenAPI的SDK,以排除SDK本身的问题。
客户代码看着没问题,应该是https代理配置错了 可以让客户看下这篇文档
http://tengine.taobao.org/document_cn/proxy_connect_cn.html 此回答整理自钉群“OpenAPI 开发者门户 - 值班服务群2群”
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。