【求助】OpenHarmony 4.0 release 中 UDP 广播问题
在 OpenHarmony 4.0 release 中,使用 UDP 发送 255.255.255.255 的全局广播时,出现{"code":2301013,"message":"Permission denied"}部分报错如下: 02-01 21:47:25.678 31083 31249 E C015b
在 OpenHarmony 4.0 release 中,使用 UDP 发送 255.255.255.255 的全局广播时,出现{"code":2301013,"message":"Permission denied"} 部分报错如下:
02-01 21:47:25.678 31083 31249 E C015b0/NetMgrSubsystem: NETSTACK [socket_exec.cpp 599] send failed, socket is 51, errno is 13
02-01 21:47:25.678 532 593 D C02500/DISP: [CallLayerFunction:51] device Id : 0
02-01 21:47:25.678 31083 31249 E C015b0/NetMgrSubsystem: NETSTACK [socket_exec.cpp 680] send failed, socket is 51, errno is 13
02-01 21:47:25.678 532 593 D C02500/DISP: [GetHdiLayer:213] id : 1
02-01 21:47:25.678 532 593 D C02500/DISP: [SetLayerCompositionType:228] CompositionType type 1
02-01 21:47:25.678 532 593 D C02500/DISP_CMD: ProcessRequestCmd: PackSection, cmd-[78] = REQUEST_CMD_SET_LAYER_BLEND_TYPE
02-01 21:47:25.678 532 593 D C02500/DISP: [CallLayerFunction:51] device Id : 0
02-01 21:47:25.678 532 593 D C02500/DISP: [GetHdiLayer:213] id : 1
02-01 21:47:25.678 532 593 D C02500/DISP: [SetLayerBlendType:235] BlendType type 3
02-01 21:47:25.678 532 593 D C02500/DISP_CMD: ProcessRequestCmd: PackSection, cmd-[70] = REQUEST_CMD_SET_LAYER_CROP
02-01 21:47:25.678 532 593 D C02500/DISP: [CallLayerFunction:51] device Id : 0
02-01 21:47:25.678 532 593 D C02500/DISP: [GetHdiLayer:213] id : 1
02-01 21:47:25.678 532 593 D C02500/DISP: [SetLayerCrop:114] id : 1 crop x: 0 y : 0 w : 1920 h : 1080
02-01 21:47:25.678 532 593 D C02500/DISP_CMD: ProcessRequestCmd: PackSection, cmd-[71] = REQUEST_CMD_SET_LAYER_ZORDER
02-01 21:47:25.678 532 593 D C02500/DISP: [CallDisplayFunction:39] device Id : 0
02-01 21:47:25.678 532 593 D C02500/DISP: [SetLayerZorder:67] layerId : 1
02-01 21:47:25.678 532 593 D C02500/DISP: [SetLayerZorder:73] zorder no change layerId 1, zorder 0
02-01 21:47:25.678 532 593 D C02500/DISP_CMD: ProcessRequestCmd: PackSection, cmd-[72] = REQUEST_CMD_SET_LAYER_PREMULTI
02-01 21:47:25.678 532 593 D C02500/DISP: [CallLayerFunction:51] device Id : 0
02-01 21:47:25.679 532 593 D C02500/DISP: [GetHdiLayer:213] id : 1
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayerPreMulti:127]
02-01 21:47:25.679 532 593 D C02500/DISP_CMD: ProcessRequestCmd: PackSection, cmd-[80] = unknow command id.
02-01 21:47:25.679 532 593 E C02500/DISP: [0;32;31m[SetLayerMaskInfo:318] <private> is not supported[m
02-01 21:47:25.679 532 593 E C02500/DISP_CMD: 823@OnSetLayerMaskInfo: check failed
02-01 21:47:25.679 532 593 D C02500/DISP_CMD: ProcessRequestCmd: PackSection, cmd-[64] = REQUEST_CMD_PREPARE_DISPLAY_LAYERS
02-01 21:47:25.679 532 593 D C02500/DISP: [CallDisplayFunction:39] device Id : 0
02-01 21:47:25.679 532 593 D C02500/DISP: [PrepareDisplayLayers:169]
02-01 21:47:25.679 532 593 D C02500/DISP: [PrepareDisplayLayers:176] mLayers size 5 layers size 5
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayerZorder:121] id : 0 zorder : 3
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayers:108] layers size 5
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [SetDeviceSelect:117] 0
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [SetDeviceSelect:117] 0
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [SetDeviceSelect:117] 0
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [SetDeviceSelect:117] 0
02-01 21:47:25.679 532 593 D C02500/DISP: [CanHandle:85]
02-01 21:47:25.679 532 593 D C02500/DISP: [SetDeviceSelect:117] 0
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayers:126] composer layers size 5
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayers:50]
02-01 21:47:25.679 532 593 D C02500/DISP: [PrepareDisplayLayers:187] layer change
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayerCompositionType:228] CompositionType type 0
02-01 21:47:25.679 532 593 D C02500/DISP: [PrepareDisplayLayers:187] layer change
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayerCompositionType:228] CompositionType type 0
02-01 21:47:25.679 532 593 D C02500/DISP: [PrepareDisplayLayers:187] layer change
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayerCompositionType:228] CompositionType type 0
02-01 21:47:25.679 532 593 D C02500/DISP: [PrepareDisplayLayers:187] layer change
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayerCompositionType:228] CompositionType type 0
02-01 21:47:25.679 532 593 D C02500/DISP: [PrepareDisplayLayers:187] layer change
02-01 21:47:25.679 532 593 D C02500/DISP: [SetLayerCompositionType:228] CompositionType type 0
02-01 21:47:25.679 532 593 D C02500/DISP: [CallDisplayFunction:39] device Id : 0
02-01 21:47:25.679 532 593 D C02500/DISP: [CallDisplayFunction:39] device Id : 0
02-01 21:47:25.679 532 593 D C02500/DISP: [GetDisplayCompChange:132] set the layers and type
02-01 21:47:25.679 31083 31083 D C03f00/ArkCompiler: [ecmascript] Throw error: Unexpected Text in JSON
02-01 21:47:25.679 31083 31083 D C03f00/ArkCompiler: [ecmascript] at formatJSON (entry/src/main/ets/LogUtil.ts:26:27)
02-01 21:47:25.679 31083 31083 D C03f00/ArkCompiler: at error (entry/src/main/ets/LogUtil.ts:48:45)
02-01 21:47:25.679 31083 31083 D C03f00/ArkCompiler: at anonymous (entry/src/main/ets/UdpClient.ts:154:25)
02-01 21:47:25.679 603 603 D C01400/Composer: PrepareCompleteIfNeed: Need flush framebuffer, client composition layer num is 5
02-01 21:47:25.679 603 603 D C01400/OHOS::RS: RsDebug RSPhysicalScreenProcessor::Redraw flush frame buffer start
02-01 21:47:25.679 31083 31083 E A00001/DnakeLog-UdpClient: send fail,{"code":2301013,"message":"Permission denied"}
应用已设置为系统权限,selinux 为关闭状态。并申请了 如下权限:
"requestPermissions": [
{
"name": "ohos.permission.INTERNET"
},
{
"name": "ohos.permission.GET_NETWORK_INFO"
},
{
"name": "ohos.permission.SET_NETWORK_INFO"
},
],
发送广播代码如下:
let udp = socket.constructUDPSocketInstance()
udp.bind({
address: '10.9.4.34'
}).then(async () => {
try {
await udp.setExtraOptions({
receiveBufferSize: 1024,
sendBufferSize: 1024,
reuseAddress: true,
socketTimeout: 6000,
broadcast: true
}).then(() => {
LogUtil.info(TAG, 'setExtraOptions success');
udp.send({
data: data,
address: {
address: '255.255.255.255', port: 9712, family: 1
}
}).then(async () => {
if (printLog) {
LogUtil.info(TAG, 'send success')
}
await this.closeSendUdp(udp)
udp = null
}).catch(async err => {
LogUtil.error(TAG, 'send fail,' + JSON.stringify(err))
await this.closeSendUdp(udp)
udp = null
})
}).catch((err) => {
LogUtil.error(TAG, 'setExtraOptions fail,' + JSON.stringify(err));
})
} catch (err) {
LogUtil.error(TAG, 'setExtraOptions fail,' + JSON.stringify(err));
}
}).catch(async err => {
LogUtil.error(TAG, 'send fail ,' + JSON.stringify(err))
await this.closeSendUdp(udp)
udp = null
})
请问 OpenHarmony 是否支持 UDP 发送 255.255.255.255 的全局广播?
更多推荐
所有评论(0)