Bad session state

Suddenly this afternoon I started getting “Bad session state” errors for a particular CPE. I’ve rebooted the CPE, CWMP and redis process to no avail. There is nothing remarkable in either the cwmp log or the debug log for the CPE. I’m not really sure how to debug this from here given that there isn’t any concrete error message. This error is occurring on my dev instance which has 3 active CPEs. This is the only CPE giving me this error.

I tried deleting the CPE from Genie and rebooted the device and still get the same error.

-dan

2019-01-21T23:46:36.454Z [INFO] 172.27.240.128 3c9066-963138_T281_C-SR555AA046%2D5000077: Inform; cpeRequestId=“1219693439” informEvent=“1 BOOT,4 VALUE CHANGE” informRetryCount=0
2019-01-21T23:46:42.552Z [ERROR] 172.27.240.128 3c9066-963138_T281_C-SR555AA046%2D5000077: Bad session state

Due to limitations of discord, I had to edit the SOAP messages below to remove http://…

REQUEST Mon Jan 21 2019 14:46:36 GMT-0900 (AKST)
{“host”:“172.24.254.12:7548”,“user-agent”:“CV2_TR69_CPE_04_00”,“connection”:“keep-alive”,“soapaction”:“”,“content-type”:“text/xml”,“content-length”:“3588”}
<SOAP-ENV:Envelope
xmlns:SOAP-ENV=“…”
xmlns:SOAP-ENC=“…”
xmlns:xsd=“…”
xmlns:xsi=“…”
xmlns:cwmp=“urn:dslforum-org:cwmp-1-0”>
<SOAP-ENV:Header>
<cwmp:ID SOAP-ENV:mustUnderstand=“1”>1219693439</cwmp:ID>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<cwmp:Inform>
<DeviceId>
<Manufacturer>SmartRG</Manufacturer>
<OUI>3c9066</OUI>
<ProductClass>963138_T281_C</ProductClass>
<SerialNumber>SR555AA046-5000077</SerialNumber>
</DeviceId>
<Event SOAP-ENC:arrayType=“cwmp:EventStruct[2]”>
<EventStruct>
<EventCode>1 BOOT</EventCode>
<CommandKey></CommandKey>
</EventStruct>
<EventStruct>
<EventCode>4 VALUE CHANGE</EventCode>
<CommandKey></CommandKey>
</EventStruct>
</Event>
<MaxEnvelopes>1</MaxEnvelopes>
<CurrentTime>2019-01-21T14:46:36+00:00</CurrentTime>
<RetryCount>0</RetryCount>
<ParameterList SOAP-ENC:arrayType=“cwmp:ParameterValueStruct[0009]”>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceSummary</Name>
<Value xsi:type=“xsd:string”>InternetGatewayDevice:1.4, X_CISCO_COM_CAH:1</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
<Value xsi:type=“xsd:string”>1.0</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
<Value xsi:type=“xsd:string”>SR555ac</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
<Value xsi:type=“xsd:string”>2.6.1.2018:12:06:15:18:05</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
<Value xsi:type=“xsd:string”></Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
<Value xsi:type=“xsd:string”>…</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
<Value xsi:type=“xsd:string”>(null)</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.WANDevice.3.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress</Name>
<Value xsi:type=“xsd:string”>172.27.240.128</Value>
</ParameterValueStruct>
<ParameterValueStruct>
<Name>InternetGatewayDevice.WANDevice.3.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress</Name>
<Value xsi:type=“xsd:string”>172.27.240.128</Value>
</ParameterValueStruct>
</ParameterList>
</cwmp:Inform>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

# RESPONSE Mon Jan 21 2019 14:46:36 GMT-0900 (AKST)
{“Server”:“GenieACS/1.1.2”,“SOAPServer”:“GenieACS/1.1.2”,“Content-Type”:“text/xml; charset="utf-8"”,“Set-Cookie”:“session=2da851ae880bfc3f”}
<?xml version=“1.0” encoding=“UTF-8”?>
<soap-env:Envelope xmlns:soap-enc=“…” xmlns:soap-env=“…” xmlns:xsd=“…” xmlns:xsi=“…” xmlns:cwmp=“urn:dslforum-org:cwmp-1-0”>
<soap-env:Header>
<cwmp:ID soap-env:mustUnderstand=“1”>1219693439</cwmp:ID>
</soap-env:Header>
<soap-env:Body>
<cwmp:InformResponse>
<MaxEnvelopes>1</MaxEnvelopes>
</cwmp:InformResponse>
</soap-env:Body>
</soap-env:Envelope>

Hmm, factory defaulting the CPE seems to have resolved the issue. Not sure why. I previously had deleted the CPE out of Genie and reboot the device and still got the “Bad session state” error. Not real sure why factory defaulting the CPE would be different, unless the CPE was sending bad data to Genie.

The error message says that the request received doesn’t match the expected message type based on the flow of the session (e.g. CPE sends Inform twice in the same session). Can’t speculate why this happened or why a factory reset seems to have solved it! Next time it happens you can take a packet capture and it should be easy to spot the issue.