我通过VPN连接使用snowflake,需要在nodejs项目上设置snowflake。 我按照https://docs.snowflake.com/en/user-guide/nodejs-driver-use.html# doc中提到的步骤操作。
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 连接,并且我的组织 VPC 中已经有
.pem
文件。我使用以下 ssh 命令来创建 ssh 隧道。
ssh -L 7756:xyz.region.privatelink.snowflakecomputing.com:443 -l user_name -N server_name -p port_number -i my_file.pem
请帮忙解决这个问题
您的 IP 似乎在 Snowflake 的网络策略中被阻止或不允许。您能否联系具有 AccountAdmin/SecurityAdmin 权限的用户以允许您的 IP 在 Snowflake 中?
参考:https://docs.snowflake.com/en/user-guide/network-policies.html
人们正在尝试连接。确保您的帐户标识符(即组织名称)在之间使用“-”而不是“.”。从雪花复制的帐户字符串使用 .然而它不起作用,它一定是 -