钉钉服务端 api 设置代理 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
9fan
V2EX    程序员

钉钉服务端 api 设置代理

  •  
  •   9fan 2024-12-19 10:50:35 +08:00 1301 次点击
    这是一个创建于 386 天前的主题,其中的信息可能已经有所发展或是发生改变。
    public static com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponseBody getFileUploadInfo() {
    GetFileUploadInfoResponse rsp;
    try {
    RuntimeOptions runtimeOptiOns= new RuntimeOptions();
    // 设置代理
    // String url = "http://192.168.0.15:9028/api";
    // runtimeOptions.setHttpProxy(url);
    rsp = storageClient1.getFileUploadInfoWithOptions(
    getSpaceId(),
    new GetFileUploadInfoRequest()
    .setUnionId(getUser(null).getUnionid())
    .setProtocol("HEADER_SIGNATURE")
    .setMultipart(false),
    new GetFileUploadInfoHeaders().setXAcsDingtalkAccessToken(getAccessToken()),
    runtimeOptions
    );
    } catch (Exception e) {
    log.error("钉盘-获取文件上传信息 异常: ", e);
    throw new ServiceException("钉盘-获取文件上传信息 异常: " + e.getMessage());
    }
    com.aliyun.dingtalkstorage_1_0.models.GetFileUploadInfoResponseBody fileInfo = rsp.getBody();
    return fileInfo;
    } 这里一设置代理就错误:com.aliyun.tea.TeaUnretryableException: Unexpected response code for CONNECT: 400
    at com.aliyun.teaopenapi.Client.execute(Client.java:1183) 其中 192.168.0.15 中的 nginx 配置:server{
    listen 9028;
    server_name localhost;
    location /api {
    proxy_pass https://api.dingtalk.com/;
    proxy_connect_timeout 60;
    proxy_read_timeout 60;
    proxy_send_timeout 60;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host 'api.dingtalk.com';
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    }
    location / {
    proxy_pass https://oapi.dingtalk.com/;
    proxy_connect_timeout 60;
    proxy_read_timeout 60;
    proxy_send_timeout 60;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host 'oapi.dingtalk.com';
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    }
    } 下面是 nginx access.log -->> 192.168.0.69 - - [19/Dec/2024:10:24:15 +0800] "CONNECT api.dingtalk.com:443 HTTP/1.1" 400 157 "-" "-" 现在是想知道怎么在 RuntimeOptions 这里面设置正确的代理,官方文档翻了又翻,确实没有相关介绍,求助各位大佬给予帮助,立正感谢
    rekulas
        1
    rekulas  
       2024-12-19 14:58:27 +08:00
    没试过,要不考虑自己加个反代代理层,就不用管钉钉怎么实现了,http 协议都可以挂上
    yulgang
        2
    yulgang  
       2024-12-19 15:12:31 +08:00
    日志里看 HTTP/1.1 400 感觉.....
     
    location /api {
    proxy_pass https://api.dingtalk.com;
    proxy_http_version 1.1; # 新加的
    proxy_connect_timeout 60;
    proxy_read_timeout 60;
    proxy_send_timeout 60;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host 'api.dingtalk.com';
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header Connection ""; # 新加的
    }
     
    或者
     
    location /api {
    proxy_pass https://api.dingtalk.com;
    proxy_http_version 1.1; # 新加的
    proxy_set_header Upgrade $http_upgrade; # 新加的
    proxy_set_header Connection "upgrade"; # 新加的
    proxy_connect_timeout 60;
    proxy_read_timeout 60;
    proxy_send_timeout 60;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host 'api.dingtalk.com';
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    }
     
    感觉下面这个能行。
    9fan
        3
    9fan  
    OP
       2024-12-24 11:16:27 +08:00
    感谢,已经把有关调用钉钉服务拆分了,直接放在有外网的机子上,直接远程调用,不代理了,已经给钉钉提工单了,没用
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2380 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 15:32 PVG 23:32 LAX 07:32 JFK 10:32
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86