reedog117 / node-vsphere-soap

Node.js module for accessing VMware vCenter/ESXi hosts using SOAP
MIT License
32 stars 15 forks source link

Error on expired session #8

Open dbussert opened 9 years ago

dbussert commented 9 years ago

Moved this from node-vsphere to node-vsphere-soap, since it appears to be an issue in the lib.

I've added this library to a hubot script that controls our Vsphere, so it will be running 24x7. I instantiate the client on start of the bot, but after time with no commands, I get this error

 error contents : <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault><faultcode>ServerFaultCode</faultcode><faultstring>The session is not authenticated.</faultstring><detail><NotAuthenticatedFault xmlns="urn:vim25" xsi:type="NotAuthenticated"><object type="Folder">group-d1</object><privilegeId>System.View</privilegeId></NotAuthenticatedFault></detail></soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
authorization token expired! reconnecting...
error contents : <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault><faultcode>ServerFaultCode</faultcode><faultstring>
Required property obj is missing from data object of type ObjectSpec

while parsing serialized DataObject of type vmodl.query.PropertyCollector.ObjectSpec
at line 1, column 584

while parsing property &quot;objectSet&quot; of static type ArrayOfObjectSpec

while parsing serialized DataObject of type vmodl.query.PropertyCollector.FilterSpec
at line 1, column 382

while parsing call information for method RetrievePropertiesEx
at line 1, column 243

while parsing SOAP body
at line 1, column 232

while parsing SOAP envelope
at line 1, column 0

while parsing HTTP request for method retrievePropertiesEx
on object of type vmodl.query.PropertyCollector
at line 1, column 0</faultstring><detail><InvalidRequestFault xmlns="urn:vim25" xsi:type="InvalidRequest"></InvalidRequestFault></detail></soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
reedog117 commented 9 years ago

How much time passes before the auth token expires? It was my understanding that the auth token expiration is lengthened each time an operation happens using that token, but I could be wrong. Let me take a look...

reedog117 commented 9 years ago

It looks like the command you may be sending may not be providing all the arguments it needs to run properly. I don't have your code so it will be harder for me to debug, but if you could go to this line https://github.com/reedog117/node-vsphere-soap/blob/master/lib/client.js#L223 and add a console.log(command, arguments); we can see if the arguments are getting dropped somewhere when reconnecting.

dbussert commented 9 years ago

@reedog117 this was found using node-vpshere. I get built a simple test harness to get all VMs via our chatbot Hubot, then came back a few hours later, triggered the command to get all the VMs and got the error the session was expired. While it makes sense for the session to expire, it seems like that should be handled by node-vsphere-soap, and not trigger errors in node-vsphere.