@ overridepublicresultdtodeleteclientid (string clientid ) {
log.info(deleteclientid设备已禁用,取消下行命令源mqtt的clientid连接,加入clientid: {}、clientid ); try{/*传递的clientid可能包含特殊字符。 首先是字符转换*/clientid=urlencoder.encode (clientid,' UTF-8 ' );
} catch (unsupportedencodingexceptione ) {
e .打印任务跟踪(; returnResultDTO.getFailure (;
//此处的子画面目标将删除客户端地址。 示例: http://127.0.0.1336018083/API/v4/clients/clientid _ test
string URL=string.format (constant config.mqtt _ dashboard _ URL _ str,ConstantConfig.getServerConfig ).getpront
closeablehttpclienthttpclient=http clients.create default (;
httpdeletehttpdelete=newhttpdelete (URL;
requestconfigrequestconfig=request config.custom (.setconnecttimeout (35000 ).setconnectionrequesttimeout ) ) 35000 )
http delete.set config (request config; //这里是emqx web登录名的密码。 示例:管理员:公共
stringauthstring=constant config.getserverconfig ().getproperty (constant config.mqtt _ dashboard _ u user ).trim ) . getproperty (constant config.mqtt _ dashboard _ password ).trim ); byte [ ] authencbytes=base64.encode base64 (authstring.getbytes ();
stringauthstringenc=new string (authencbytes;
http delete.setheader (' authorization ',' Basic' authStringEnc );
http delete.setheader (' content-type ',' application/json ' );
HTP delete.setheader (数据编码),UTF-8 );
closeablehttpresponsehttpresponse=null; 通过try//http请求访问。
httpresponse=http client.execute (http delete;
httpentityentity=httpresponse.get entity (; //获得删除结果
string result=entity utils.tostring (entity;
} catch (clientprotocolexceptione ) )
e .打印任务跟踪(; returnResultDTO.getFailure (;
}catch(ioexceptione ) {
e .打印任务跟踪(; returnResultDTO.getFailure (;
(finally ) if ) httpresponse!=null ) {try{
httpResponse.close (;
}catch(ioexceptione ) {
e .打印任务跟踪(;
}
(if )空值!=http客户端) {try{
httpClient.close (;
}catch(ioexceptione ) {
e .打印任务跟踪(;
}
}
}returnResultDTO.getSuccess (;
}