问题描述:
由于要以“Device.”为根节点读取CPE的所有配置文件,报文交互超过千次,导致超过一次连接所允许的默认最大连接次数(100),导致获取失败。
解决过程:
1.使用Wireshark捕获ACS与CPE的交互报文,发现多次连接终止在同一个报文处,且此次报文交互过程中,Http请求头中Connection为状态由上一次的keep-alive变为close,标志ACS主动关闭了此次连接。因此猜测一次连接所允许的报文交互次数是有限制的。
POST /acs HTTP/1.1
Host: 10.88.120.46:7547
User-Agent: gSOAP/2.8
Content-Type: text/xml; charset=utf-8
Content-Length: 795
Connection: keep-alive
SOAPAction: Inform
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://tempuri.org/wsdl.xsd"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand="1">1634113257645</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cwmp:GetParameterNamesResponse>
<ParameterList SOAP-ENC:arrayType="cwmp:ParameterInfoStruct[1]">
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.UEStatusMgmt.UECount</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
</ParameterList>
</cwmp:GetParameterNamesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP/1.1 200
Content-Type: text/xml;charset=utf-8
Content-Length: 597
Date: Wed, 13 Oct 2021 08:21:02 GMT
Keep-Alive: timeout=60
Connection: keep-alive
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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">1634113257658</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cwmp:GetParameterNames>
<ParameterPath>Device.Services.FAPService.1.CellConfig.1.NR.RAN.</ParameterPath>
<NextLevel>true</NextLevel>
</cwmp:GetParameterNames>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>POST /acs HTTP/1.1
Host: 10.88.120.46:7547
User-Agent: gSOAP/2.8
Content-Type: text/xml; charset=utf-8
Content-Length: 1627
Connection: keep-alive
SOAPAction: Inform
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://tempuri.org/wsdl.xsd"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand="1">1634113257658</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cwmp:GetParameterNamesResponse>
<ParameterList SOAP-ENC:arrayType="cwmp:ParameterInfoStruct[7]">
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.RAN.Common.</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.RAN.Mobility.</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.RAN.NeighborList.</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.RAN.RF.</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.RAN.RRCTimers.</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.RAN.PHY.</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.RAN.CellRestriction.</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
</ParameterList>
</cwmp:GetParameterNamesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
HTTP/1.1 200
Content-Type: text/xml;charset=utf-8
Content-Length: 597
Date: Wed, 13 Oct 2021 08:21:03 GMT
Connection: close
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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">1634113257671</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cwmp:GetParameterNames>
<ParameterPath>Device.Services.FAPService.1.CellConfig.1.NR.NGC.</ParameterPath>
<NextLevel>true</NextLevel>
</cwmp:GetParameterNames>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>POST /acs HTTP/1.1
Host: 10.88.120.46:7547
User-Agent: gSOAP/2.8
Content-Type: text/xml; charset=utf-8
Content-Length: 1279
Connection: close
SOAPAction: Inform
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://tempuri.org/wsdl.xsd"
xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand="1">1634113257671</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cwmp:GetParameterNamesResponse>
<ParameterList SOAP-ENC:arrayType="cwmp:ParameterInfoStruct[4]">
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.NGC.cellReservedForOtherUse</Name>
<Writable>true</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.NGC.MaxPLMNIdentityInfoListEntries</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.NGC.PLMNIdentityInfoListNumberOfEntries</Name>
<Writable>false</Writable>
</ParameterInfoStruct>
<ParameterInfoStruct>
<Name>Device.Services.FAPService.1.CellConfig.1.NR.NGC.PLMNIdentityInfoList.</Name>
<Writable>true</Writable>
</ParameterInfoStruct>
</ParameterList>
</cwmp:GetParameterNamesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
2.查询度娘后,确定需设置SpringBoot内置容器的maxKeepAliveRequest参数。
maxKeepAliveRequest:多少次请求后keepalive断开失效
@Configuration
public class TomcatUtil {
@Value("${server.additionalPorts}")
private String additionalPorts;
@Bean
public TomcatServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
Connector[] additionalConnectors = this.additionalConnector();
if (additionalConnectors != null && additionalConnectors.length > 0) {
tomcat.addAdditionalTomcatConnectors(additionalConnectors);
}
return tomcat;
}
private Connector[] additionalConnector() {
if (StringUtils.isBlank(this.additionalPorts)) {
return null;
}
String[] ports = this.additionalPorts.split(",");
List<Connector> result = new ArrayList<>();
for (String port : ports) {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(Integer.valueOf(port));
((Http11NioProtocol) connector.getProtocolHandler()).setMaxKeepAliveRequests(100000);
result.add(connector);
}
return result.toArray(new Connector[] {});
}
}
PS:该类还为内置容器添加了一个额外的访问端口。(@Value("${server.additionalPorts}")注入,在application.yml中配置)
# 开发环境配置
server:
# 服务器的HTTP端口,默认为8080
port: 8080
additionalPorts: 7547
servlet:
# 应用的访问路径
context-path: /
tomcat:
# tomcat的URI编码
uri-encoding: UTF-8
# tomcat最大线程数,默认为200
max-threads: 800
# Tomcat启动初始化的线程数,默认值25
min-spare-threads: 30
3.再次进行测试,发现仍然失败,使用Wireshark读取报文发现,此次为交互超过1000次时,CPE主动关闭连接,获取Http响应头中的Connection状态,重新发起新的连接即可。