Skip to content

Conversation

@uint0
Copy link
Contributor

@uint0 uint0 commented Aug 30, 2022

Currently connections using https: false still attempt to use the https.Agent. This causes thrift to throw an error. This PR uses the plain http.Agent in the case https: false in order to fix this.

Code + Error
const client = new DBSQLClient(); const conn = await client.connect({ host: "redacted", path: "redacted", // other options https: false, ssl: false, headers: {'X-redacted': 'true'}, }); const sess = await conn.openSession(); const queryOp = await sess.executeStatement('SELECT "Hello, World!"', { runAsync: true }); const result = await queryOperation.fetchAll(); console.table(result); await queryOperation.close(); await sess.close(); await conn.close();
TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:" at new NodeError (node:internal/errors:393:5) at new ClientRequest (node:_http_client:186:11) at Object.request (node:http:97:10) at HttpConnection.write (/databricks-sql-nodejs-main/node_modules/thrift/lib/nodejs/lib/thrift/http_connection.js:223:12) at TBufferedTransport.writeCb [as onFlush] (/databricks-sql-nodejs-main/node_modules/thrift/lib/nodejs/lib/thrift/create_client.js:47:16) at TBufferedTransport.flush (/databricks-sql-nodejs-main/node_modules/thrift/lib/nodejs/lib/thrift/buffered_transport.js:181:10) at TCLIServiceClient.send_OpenSession (/databricks-sql-nodejs-main/thrift/TCLIService.js:2198:24) at TCLIServiceClient.OpenSession (/databricks-sql-nodejs-main/thrift/TCLIService.js:2184:10) at /databricks-sql-nodejs-main/dist/hive/Commands/BaseCommand.js:19:25 at new Promise (<anonymous>) { code: 'ERR_INVALID_PROTOCOL' } 
Signed-off-by: Chen Zhou <i@uint0.dev>
Co-authored-by: Levko Kravets <levko.ne@gmail.com>
@kravets-levko kravets-levko merged commit 8bbf410 into databricks:main Aug 30, 2022
@uint0 uint0 deleted the http-agent-support branch August 30, 2022 12:41
@kravets-levko
Copy link
Contributor

Thank you @uint0!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants