@@ -89,12 +89,23 @@ while true
',"ts_030_unix-translator_received":' + ts +
',' + timestamps_plus_json_blob
- # TODO: fix so sending new_json_blob to SGX, and via POST- response = Net::HTTP.get_response(- URI("https://#{ARGV[1]}:#{ARGV[2]}/r2tst.php")- )-- puts "TODO - response.code = #{response.code} and body #{response.body}"
+ uri = URI("http://#{ARGV[1]}:#{ARGV[2]}/")
+ req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
+ req.body = "{#{new_json_blob}}" # TODO: should just be MSG part (?)
+ begin
+ res = Net::HTTP.start(uri.hostname, uri.port) do |http|
+ http.request(req)
+ end
+ # list of exceptions is from https://stackoverflow.com/a/5370726
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
+ Net::ProtocolError => e
+
+ puts "TODO problem '#{e}' - now we should try again..."
+ # TODO: actually try again
+ else
+ puts "TODO - res: '#{res.code}' '#{res.message}': '#{res.body}'"
+ end
# if SGX gives back anything but response.code 200, retry 5 times-ish
# if SGX failed to respond after retries, email or other notify