最近在接tr069的东西。但是遇到一点问题,
- 首先就是他的心跳能不能返回一些命令
- 其二就是我使用了心跳连接给他 writeAndFlush(response)过后照理说他会马上再进来。带一个空的请求。然后我继续writeAndFlush(response)命令。但是我第一个writeAndFlush他并没有进来,抓包应该是有这个空的请求的
使用的是netty
以下是心跳进来过后的流程
result="<SOAP-ENV:Envelope xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
" <SOAP-ENV:Header>" +
" <cwmp:ID SOAP-ENV:mustUnderstand=\"1\">{0}</cwmp:ID>" +
" <cwmp:NoMoreRequests>0</cwmp:NoMoreRequests>" +
" </SOAP-ENV:Header>" +
" <SOAP-ENV:Body>" +
" <cwmp:InformResponse xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\"><MaxEnvelopes>1</MaxEnvelopes>" +
" </cwmp:InformResponse>" +
" </SOAP-ENV:Body>" +
"</SOAP-ENV:Envelope>";
//将会话ID替换了
String res = MessageFormat.format(result,sss);
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK, Unpooled.wrappedBuffer(res.getBytes("UTF-8")));
response.headers().set(CONTENT_TYPE, "text/xml");
response.headers().set(CONTENT_LENGTH, response.content().readableBytes());
// 发送响应
ChannelFuture channelFuture = channelHandlerContext.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);