我通过 VPN 连接使用雪花,需要在 nodejs 项目上设置雪花。我遵循了https://docs.snowflake.com/en/user-guide/nodejs-driver-use.html# doc中提到的这些步骤。
- nodejs 版本 v12.18.0
- 安装雪花 SDK(版本 1.6.1)
const snowflake = require('snowflake-sdk');
snowflake.configure({ ocspFailOpen: false });
const snowflakeDatabase = {
accessUrl:
'https://xyz.region.privatelink.snowflakecomputing.com:7756',
account: 'xyz.region.privatelink',
authenticator: 'SNOWFLAKE',
username: 'my_user_name',
password: 'my_password',
insecureConnect: true,
clientSessionKeepAlive: true,
jsTreatIntegerAsBigInt: true,
};
connection = snowflake.createConnection(snowflakeDatabase);
createPool = () => {
if (!connection) {
connection = snowflake.createConnection(snowflakeDatabase);
}
if (!connection.isUp()) {
connection.connect(function (err, conn) {
if (err) {
console.error('Unable to connect: ' + err.message);
} else {
console.log('Successfully connected to Snowflake.');
// Optional: store the connection ID.
connection_ID = conn.getId();
}
});
console.log('connection status:', connection.isUp());
}
return connection;
};
closePool = () => {
connection.destroy(function (err, conn) {
if (err) {
console.error('Unable to disconnect: ' + err.message);
} else {
console.log(
'Disconnected connection with id: ' + connection.getId()
);
}
});
};
module.exports = {
createPool: createPool,
closePool: closePool,
};
但它返回以下响应
(node:10188) UnhandledPromiseRejectionWarning: OperationFailedError: IP {{IP_ADDRESS}} is not allowed to access Snowflake. Contact your local security administrator.
at createError (myfolder\node_modules\snowflake-sdk\lib\errors.js:529:15)
at Object.exports.createOperationFailedError (myfolder\node_modules\snowflake-sdk\lib\errors.js:308:10)
at Object.callback (myfolder\node_modules\snowflake-sdk\lib\services\sf.js:624:28)
at Request.<anonymous> (myfolder\node_modules\snowflake-sdk\lib\http\base.js:107:19)
at Request._callback (myfolder\node_modules\lodash\lodash.js:10118:25)
at Request.requestRetryReply [as reply] (myfolder\node_modules\requestretry\index.js:115:19)
at Request.<anonymous> (myfolder\node_modules\requestretry\index.js:156:10)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:10188) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:10188) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
在这里,我使用了 VPN 连接,并且我已经有.pem
文件到我的组织 VPC。我使用以下 ssh 命令创建 ssh 隧道。
ssh -L 7756:xyz.region.privatelink.snowflakecomputing.com:443 -l user_name -N server_name -p port_number -i my_file.pem
请帮助解决这个问题