jakecraige
jakecraige

Reputation: 2727

GET request will not return only within Node.JS?

For some reason this request GET never returns, but only in Node.js. I've tried in browser, curl, httparty, ruby's Net::Http, postman, clojure and they all work fine. Node.js will not.

This will return as you'd expect

echo "require('https').get('https://github.com/jakecraige.json', function(res) { console.log(res); });" | node

This never will return, it eventually throws an ECONNRESET

echo "require('https').get('https://gateway.rpx.realpage.com/rpxgateway/PricingAndAvailability.svc?wsdl', function(res) { console.log(res); });" | node

If anyone could provide some insight into this that would be extremely helpful.

Thanks!

Upvotes: 0

Views: 179

Answers (4)

Jay
Jay

Reputation: 496

Combining @Constarr links with this original post I have this constructed request getting a valid response.

var https = require('https');
https.globalAgent.options.secureProtocol = 'SSLv3_method';

https.get("https://gateway.rpx.realpage.com/rpxgateway/PricingAndAvailability.svc?wsdl", function(res) {
  console.log("Got response: " + res.statusCode);
}).on('error', function(e) {
  console.log("Got error: " + e.message);
});            

Docs here

Upvotes: 0

Amadan
Amadan

Reputation: 198486

Your code hangs for me whichever URL I pick. I believe that's node trying to make sure we don't exit prematurely, running its event loop just in case. All other techniques you listed are synchronous, not event-driven. Also, res is probably not what you want to print, since it's the node's internal response object. Try this:

cat <<EOF | node
require("https").get("https://github.com/jakecraige.json",
  function(res) {
    var body = ''
    res.
      on('data', function(data) { body += data}).
      on('end', function() { console.log(body); process.exit(0); });
  }
);
EOF

Upvotes: 0

jakecraige
jakecraige

Reputation: 2727

Zyrri in IRC directed me to here which solved the problem.

SSL Error in nodejs

Looks like it wants SSLv3_method from node.js

Upvotes: 1

chovy
chovy

Reputation: 75834

$ curl 'https://gateway.rpx.realpage.com/rpxgateway/PricingAndAvailability.svc' -I
HTTP/1.1 400 Bad Request

Try providing an error handler and see what you get.

Upvotes: 0

Related Questions