I've set up a Watir-Webdriver script which I want to report to a remote service:
puts "Starting..."
b = Watir::Browser.new :ie
puts "Started browser"
puts "Setting status as non-idle"
request = Net::HTTP::Post.new()
url = URI(HOME + '/update_status')
request.body = JSON.generate({ scrapeId: SCRAPE_ID, status: 'working' })
# This step freezes processing
Net::HTTP.start(url.host, url.port) {|http| http.request(request)}
puts "This step never happens"
At the same time, node.js/express watir is pinging to has the following endpoint:
app.post('/update_status', function(req, res) {
redis.hset(req.body.scrapeId, 'status', req.body.status);
if (req.body.status === 'finished') {
redis.expire(req.body.scrapeId, SIX_HOURS);
}
res.send('response from post /update_status');
});
Question: Why is Net::HTTP timing out when hitting /update_status
? Interestingly, if server returns 404 (endpoint doesn't exist), Watir script continues normally.
Net::ReadTimeout
is obviously the culrpit, but why?
"Assumption is the mother of all problems" - paraphrasing some very smart guy or gal.
The answer was as simple as it was silly - I added a node.js middleware omitting the next();
in it. Nothing wrong with the script, as it turns out - I was looking in the wrong place and didn't have a test for it. Whoops.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With