【问题标题】:Dynamodb localhost:8000 connection failing due to proxy errorDynamodb localhost:8000 连接因代理错误而失败
【发布时间】:2018-03-18 03:15:31
【问题描述】:

我可以使用这个命令在本地启动 Dynamodb -

java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb

我收到对上述命令的以下响应-

    Initializing DynamoDB Local with the following configuration:
Port:   8000
InMemory:       false
DbPath: null
SharedDb:       true
shouldDelayTransientStatuses:   false
CorsParams:     *

但是,当我在 AWS CLI 上输入以下命令以设置本地端点时-

aws dynamodb list-tables --endpoint-url http://localhost:8000

我遇到了错误-

  An error occurred (504) when calling the ListTables operation (reached max retries: 9): <HTML>
    <HEAD><TITLE>The Proxy Was Unable to Fulfill Your Request</TITLE></HEAD>
    <BODY>
    <H1>The Proxy Was Unable to Fulfill Your Request</H1>
    <HR SIZE="1">
    <P>The proxy was unable to fulfill your request because it could not contact the computer at localhost:8000 (Connection reset by peer).</P>
    <P>The website may be temporarily unavailable. If later attempts to access this website are still unsuccessful, you may wish to contact the website's adminis
    tor.
    </P>
<HR SIZE="1">
</BODY>
</HTML>

我的 PC 的本地代理设置为绕过本地地址,包括 localhost。我也尝试使用 CLI 设置 AWS HTTP 和 HTTPS 代理。但它没有用。然后我尝试使用 AWS Eclipse 插件并使用它,我可以连接到本地主机上的 dynamodb(仅通过 Eclipse,而不是通过 CLI)。我希望能够使用 CLI 来处理本地 dynamodb。

请帮忙。

谢谢, 库纳尔

【问题讨论】:

标签: localhost amazon-dynamodb http-proxy


【解决方案1】:

如果您想查看表格列表,请在http://localhost:8000/shell/上执行以下脚本

var dynamodb = new AWS.DynamoDB({
    region: 'us-east-1',
    endpoint: "http://localhost:8000"
});

var params = {
};

function doPrint(response) {
    if (response.error) ppJson(response.error); // an error occurred
    else {
        ppJson(response.data); // successful response
    }
}


console.log("List of tables");
dynamodb.listTables(params)
    .on('complete', doPrint)
    .send();

【讨论】:

  • 谢谢。我可以使用 JS shell 查看表格列表。有没有办法使用非 JS shell?
  • 由于您的机器上有一些代理设置,因此调试或建议解决方案并不困难。我的回答是为其提供替代方案,而不是解决代理问题。如果您出于其他目的需要解决计算机上的 CLI 问题,您可能需要寻找其他解决方案。
  • 我同意。我会尝试其他解决方案。
【解决方案2】:

我通过添加以下 Windows 环境变量解决了这个问题-

HTTP_PROXY = http://<My-Proxy-Host>:<My-Proxy-Port>
HTTPS_PROXY = http://<My-Proxy-Host>:<My-Proxy-Port>
NO_PROXY= localhost

请务必重新启动电脑以反映这些设置。

希望对有需要的人有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    相关资源
    最近更新 更多