首页 > 编程知识 正文

参数clientid不能为空,java tcp ip自动重连

时间:2023-05-04 11:14:10 阅读:107282 作者:39

@ 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 (;

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。