tagomoris / presto-client-node

Distributed query engine Presto client library for node.js
MIT License
126 stars 57 forks source link

When nextUri is returned without a specified port, ERR_SOCKET_BAD_PORT is returned #38

Open edwardflo opened 4 years ago

edwardflo commented 4 years ago

When Presto returns a nextUri without a specified port number(e.g. http://prestoserver/v1/api/...), the following error is returned: RangeError: Port should be >= 0 and < 65536. Received .RangeError [ERR_SOCKET_BAD_PORT]: Port should be >= 0 and < 65536. Received .

This is due to the opts.port being an empty string when making a subsequent request due to: https://github.com/tagomoris/presto-client-node/commit/5b879892ae147c2f7013c7dfd0a2217469c36eff#diff-bc0ed6253188f59cfb43f199aaea9eabR57-R67

Specifically, line 59, URL returns href.port as ''.

The way to fix this is to add the following at line 69: if (opts.port === '') delete opts.port; or opts.port = client.port;

My scenario is not an unusual situation. I simply have a firewall forwarding port 80 (as well as 443) to the presto coordinator on port 8080. The above error is seen when trying to contact it using port 80 or port 443 (with ssl turned on).

Would you be able to add one of the above-mentioned fixes?

Thanks

tagomoris commented 4 years ago

37 ?

tagomoris commented 4 years ago

This should be fixed at v0.8.1 https://www.npmjs.com/package/presto-client/v/0.8.1