阿里云短信服务,云视频点播服务出现proxy url is invaild错误解决方式

错误:

在这里插入图片描述

分析

这大概是电脑代理设置出了问题,因此需要对http代理进行设置。

解决方式

在初始化client的函数中要设置http代理,因此需要使用HttpClientConfig进行配置,并且要设置到profile中。
【关键代码】

		HttpClientConfig clientConfig = HttpClientConfig.getDefault();
        clientConfig.setHttpProxy("http://127.0.0.1:10810");
        clientConfig.setHttpsProxy("http://127.0.0.1:10810");
        profile.setHttpClientConfig(clientConfig);

我本地的Http代理挂在了10810端口,这需要根据本地电脑进行配置。

【查看方式】
win10平台,打开设置,搜索“代理”,查看代理服务器的端口即可。

	public static DefaultAcsClient initVodClient(String accessKeyId, String accessKeySecret) throws ClientException {
    
    
        String regionId = "cn-shanghai";  // 点播服务接入区域
        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
        HttpClientConfig clientConfig = HttpClientConfig.getDefault();
        clientConfig.setHttpProxy("http://127.0.0.1:10810");
        clientConfig.setHttpsProxy("http://127.0.0.1:10810");
        profile.setHttpClientConfig(clientConfig);
        DefaultAcsClient client = new DefaultAcsClient(profile);
        return client;
    }

目前就可以请求获取阿里云视频点播的播放地址和视频凭证了,也可以发送短信到用户手机了。

猜你喜欢

转载自blog.csdn.net/weixin_38708854/article/details/107313065