HarmonyOS rcp请求问题?

const sessionConfig: rcp.SessionConfiguration = {
  // interceptors: {},
  baseAddress: "https://192.168.0.11/appservice",
  requestConfiguration: {
    transfer: {
      autoRedirect: true,
      timeout: {
        connectMs: 20000, //允许建立连接的最长时间(以毫秒为单位)
        transferMs: 20000, //允许传输数据的最长时间(以毫秒为单位)
      },
    },
    tracing: {
      verbose: true,
    },
    security: {
      remoteValidation: 'skip'//取消验证ssl证书
    },
  },
};

let req = new rcp.Request("/post", "PSOT", header, params);

在rcp.SessionConfiguration设置baseAddress无效,请求会报错Rcp session list: ["0"] after create: undefined。

const session = rcp.createSession(sessionConfig); let req = new rcp.Request("https://xxxxx/post", "POST", header, params); session.fetch(req).then(async(res:rcp.Response)

如上请求时候偶尔还是会出现报错Rcp session list: ["0"] after create: undefined或者Rcp session list: ["0","1","2"] after create: undefined重新debug一次又正常了。

阅读 481
1 个回答
logo
HarmonyOS
子站问答
访问
宣传栏