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一次又正常了。

阅读 482
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
HarmonyOS
子站问答
访问
宣传栏