Getting Invalid Response
See original GitHub issueI’m using pynetgear in a hass.io rpi system to monitor presence by probing the device list on my Netgear Nighthawk X10 R9000 (hitting it about every 30 seconds with a query). The system works about 80% of the time and I’m able to get the list of devices without issue but for 10% of the time (and it seems random/sporadic) I get the following error:
2019-05-28 20:41:06 ERROR (SyncWorker_1) [pynetgear] Invalid response
2019-05-28 20:41:06 DEBUG (SyncWorker_1) [pynetgear] 200
{'Content-Length': '1518', 'Content-Type': 'text/xml; charset="UTF-8"', 'Server': 'Linux/2.6.15 uhttpd/1.0.0 soap/1.0'}
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetAttachDeviceResponse xmlns:m="urn:NETGEAR-ROUTER:service:DeviceInfo:1">
<NewAttachDevice><!-- snipped for privacy --></NewAttachDevice>
</m:GetAttachDeviceResponse>
<ResponseCode>000</ResponseCo</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
2019-05-28 20:41:06 ERROR (SyncWorker_1) [pynetgear] Get attached devices failed
Clearly the XML that is printed out in the debug log is invalid:
<ResponseCode>000</ResponseCo</SOAP-ENV:Body>
At first I thought it might be random dropped packets losing the response… but it is consistent in not printing the full <ResponseCode> tag. Sometimes it breaks at different spots where it only prints </Respon but it is always this closing tag that is printed.
The question is… is this actually coming from the netgear… or is this some sort of preprocessing of the response that corrupts it within pynetgear?
Either way, I see you don’t actually validate the XML any way around this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)

Top Related StackOverflow Question
Same issue here, you’re not alone…
Thanks all for the detailed analysis, I have incorporated the suggested changes. Sorry for the tremendous delay, but I have been a quite more busy than usual and also don’t own anymore any Netgear devices with stock firmware.