Hello,
I'm having an issue getting an expected response via TCPSocket. My goal
is to connect to a remote controller device and access XML data.
The following code properly authenticates a connection, however I am not
getting the response I expect.
CODE USED:
require "socket"
#set proxy server
host = "host" #removed specifics
port = "port" #removed specifics
#set parameters for send message
user = "XXX" #removed specifics
pass = "XXX" #removed specifics
mac = "XXX" #removed specifics
limit = 10
start_time = "20100910_120000"
end_time = "20100910_123000"
#format the send message required
message = "User: #{user}
Pass: #{pass}
MAC: #{mac}
Limit: #{limit}
Start: #{start_time}
End: #{end_time}
Finish"
#open TCP socket
s = TCPSocket.open(host, port)
#send the message to controller
s.write(message)
#read and print the response (specify number of bytes)
xml = s.recv(1000)
puts xml
#close the socket
s.close
This code outputs:
"api.heliodyne.com at your service, [draker.labs]"
However, the manufacturer is showing the XML that I should be able to
access in his debug file
"SensorQueryReader] constructBean Finish
2010-09-15 13:57:06,473 DEBUG [Thread-18837]
[heliodyne.data.impl.SensorQueryReader] constructBean draker.labs was
authenticated
2010-09-15 13:57:06,478 INFO [Thread-18837]
[heliodyne.data.impl.SensorQueryWriter] writeXML Found 2 data sets for
00:90:c2:db:7a:e8 from 2010-09-10 12:00:00.0 to 2010-09-10 12:30:00.0
2010-09-15 13:57:06,478 INFO [Thread-18837]
[heliodyne.data.impl.SensorQueryWriter] writeXML
<Set><ReadingTime>2010-09-10 12:19:01.0</ReadingTime><T1
units='F'>197.64</T1><T2 units='F'>154.8</T2><T3 units='F'>160.4</T3><T4
units='F'>159.04</T4><T5 units='F'>165.3</T5><T6 units='F'>164.2</T6><T7
units='F'>181.95</T7><VFSFlow units='GPM'>17.58</VFSFlow><PulseFlow
units='GPM'>0.0</PulseFlow><Pressure units='PSI'>59.54</Pressure><Energy
units='kBTU'>138.90959</Energy></Set>
2010-09-15 13:57:06,478 INFO [Thread-18837]
[heliodyne.data.impl.SensorQueryWriter] writeXML Finished writing XML
2010-09-15 13:57:06,478 INFO [Thread-18837]
[heliodyne.data.socket.SocketHandler] run Connection 143 closed"
Any ideas why I'm not able to see the outputed XML like shown in the
debug message? Any help is much appreciated.
Thanks,
Adam
···
--
Posted via http://www.ruby-forum.com/.