如何在NodeJS中的代理后面使用DocumentDB [英] How to use DocumentDB behind a Proxy in NodeJS
问题描述
在NodeJS中,我正在尝试使用Documentdb库连接到Cosmos DB,就像azure文档的入门者在TODO List Example中说的那样. 此处的教程
In NodeJS I`m trying to connect to a Cosmos DB using the Documentdb library, as the getting starter of the azure documentation says in the TODO List Example. Tutorial Here
如果我使用的互联网不位于代理服务器后面,则可以使用.
If I use an Internet that is not behind a proxy it works.
这是连接代码:
var DocumentDBClient = require('documentdb').DocumentClient;
var docDbClient = new DocumentDBClient(config.host, {
masterKey: config.authKey
});
但是当我位于代理之后,连接就永远不会发生.我收到错误:连接ETIMEDOUT"
But when I'm behind a proxy, the connection never occur's. I`m getting an "Error: connect ETIMEDOUT"
在其他节点JS应用程序中,如果要发出Web服务请求,则只需为该请求配置代理.例如,请求:
In other node JS apps, if I want to make a request of a webservice, I just configure the proxy for the request. For example with request:
request = require('request').defaults({
proxy:'http://USERNAME:PASSWORD@proxy.url.com:8080',
});
是否可以在DocumentDB中配置代理以连接到Azure(NodeJS)中的数据库?
Is there a way to configure the proxy in DocumentDB to connect to the DB in Azure (NodeJS)?
推荐答案
我没有亲自尝试过,但是我浏览了SDK的源代码,发现ConnectionPolicy
有一个名为ProxyUrl
的参数.您可以尝试以下方法吗?
I've not personally tried it but I was going through the source code of the SDK and found out that ConnectionPolicy
has a parameter called ProxyUrl
. Can you try something like the following:
var connectionPolicy = new DocumentBase.ConnectionPolicy();
connectionPolicy.ProxyUrl = 'http://USERNAME:PASSWORD@proxy.url.com:8080';
var docDbClient = new DocumentDBClient(config.host, {
masterKey: config.authKey
}, connectionPolicy);
这篇关于如何在NodeJS中的代理后面使用DocumentDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!