HarmonyOS TLSSocket发送消息报错
TLS socket单向认证。建立连接后发送数据控制台 [tls_socket.cpp 1195] write failed, return, err: 5错误。
建立连接代码如下:
public async connect() {
if (this.isConnected) {
return
}
let ipAddress : socket.NetAddress = {} as socket.NetAddress
ipAddress.address = this.server
ipAddress.port = this.port
let options: socket.TLSConnectOptions = {
address: {
address: this.server,
port: this.port,
family: 1
},
secureOptions: {
},
ALPNProtocols: ["spdy/1", "http/1.1"]
}
let localAddress: socket.NetAddress = { address: "0.0.0.0", family: 1 }
await this.socket.bind(localAddress)
this.socket.on('message', async (value) => {
})
this.socket.connect(options, (err: BusinessError) => {
if (err) {
Logger.debug("socket connect failed: " + JSON.stringify(err), "socket")
return
}
Logger.debug("socket did connect", "socket")
})
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
问题:
- bind方法是必须调用的吗,localAddress是本地真实IP,还是0.0.0.0就可以?
- 客户端单向认证服务端,只验证服务端证书是否系统根证书授信,TLSConnectOptions要如何传递呢,这种情况secureOptions传空可以吗?
有完整的tlssocket调用示例吗
HarmonyOS
赞
收藏 0
回答 1
相关问题
HarmonyOS TLSSocket发送字节数组异常data is not string
638浏览 • 1回复 待解决
HarmonyOS socket.TLSSocket发送Uint8Array对象
627浏览 • 1回复 待解决
HarmonyOS postman 发送推送消息失败
1348浏览 • 0回复 待解决
ets TCPSocket连接无法发送消息?
4736浏览 • 1回复 待解决
HarmonyOS 发送通知消息,收到消息没有声音提醒、没有横幅消息展示
1542浏览 • 1回复 待解决
HarmonyOS 发送通知消息,收到消息没有声音提醒、没有横幅消息展示?
1127浏览 • 0回复 待解决
HarmonyOS PushKit支持发送消息给所有该应用的广播消息吗
794浏览 • 1回复 待解决
HarmonyOS TCPSocket怎么进行PB类型的消息发送
717浏览 • 1回复 待解决
webview如何进行消息的发送以及接收?
1333浏览 • 1回复 待解决
HarmonyOS react native如何向B端(RN前端)发送消息
1087浏览 • 1回复 待解决
HarmonyOS原生如何通过emit方式发送消息给rn
925浏览 • 2回复 待解决
HarmonyOS 怎么接受web端发送过来的消息
583浏览 • 1回复 待解决
宿主线程如何向worker子线程发送消息?
1141浏览 • 1回复 待解决
宿主线程如何接收子线程发送的消息?
1196浏览 • 1回复 待解决
HarmonyOS 使用udp send方法发送消息时提示Bad file descriptor
809浏览 • 1回复 待解决
HarmonyOS 使用liveeventbus通过post发送消息如何区分同步还是异步?
463浏览 • 1回复 待解决
HarmonyOS 发送通知扩展消息,如果不想替换标题和内容怎么处理
828浏览 • 1回复 待解决
HarmonyOS TLSSocket 单向认证,ca证书错误
909浏览 • 1回复 待解决
HarmonyOS TLSSocket为什么强制需要bind
824浏览 • 1回复 待解决
基于TLSSocket的通信能力
1486浏览 • 1回复 待解决
HarmonyOS tlssocket websocket实现双向认证长连接
1000浏览 • 1回复 待解决
HarmonyOS 推送消息发送成功,回执状态码是0,但是手机端未收到
1228浏览 • 1回复 待解决
HarmonyOS 服务端调用Push Kit发送通知消息,返回31错误码
903浏览 • 1回复 待解决
HarmonyOS 使用push kit在AGC控制台发送消息,提示token不合法
745浏览 • 1回复 待解决
HarmonyOS 一个事件的消息如何发送给Tabs当前选中的Page
759浏览 • 1回复 待解决
1、目前TLSSocket的客户端确实是需要bind,因为tls里面是在bind时候才创建连接。只有TLSSocket客户端必须bind,其他连接bind是可选的
2、本地IP使用0.0.0.0也可以
3、TLSConnectOptions传递方式可参考此链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/js-apis-socket-V5#connect9
4、secureOptions不可以传空,具体内容可参考上方文档