首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何连接moto独立服务器?

如何连接moto独立服务器?
EN

Stack Overflow用户
提问于 2017-12-18 22:14:13
回答 0查看 394关注 0票数 3

我刚刚安装了moto,并尝试使用以下node.js代码连接到独立服务器:

代码语言:javascript
复制
const AWS = require('aws-sdk')
const ep = new AWS.Endpoint('http://127.0.0.1:5000')
const route53 = new AWS.Route53({endpoint: ep})

const params = {}
console.log(route53.listHostedZones(params))

这段代码设置了亚马逊网络服务的endpoint,它指向moto的独立服务器。然后向端点发送listHostedZones请求。此程序的输出为

代码语言:javascript
复制
Request {
domain: null,
service:
Service {
    config:
    Config {
        credentials: [Object],
        credentialProvider: [Object],
        region: undefined,
        logger: null,
        apiVersions: {},
        apiVersion: null,
        endpoint: [Object],
        httpOptions: [Object],
        maxRetries: undefined,
        maxRedirects: 10,
        paramValidation: true,
        sslEnabled: true,
        s3ForcePathStyle: false,
        s3BucketEndpoint: false,
        s3DisableBodySigning: true,
        computeChecksums: true,
        convertResponseTypes: true,
        correctClockSkew: false,
        customUserAgent: null,
        dynamoDbCrc32: true,
        systemClockOffset: 0,
        signatureVersion: null,
        signatureCache: true,
        retryDelayOptions: {},
        useAccelerateEndpoint: false },
    endpoint:
    Endpoint {
        protocol: 'http:',
        host: '127.0.0.1:5000',
        port: 5000,
        hostname: '127.0.0.1',
        pathname: '/',
        path: '/',
        href: 'http://127.0.0.1:5000/',
        constructor: [Object] },
    _clientId: 1 },
operation: 'listHostedZones',
params: {},
httpRequest:
HttpRequest {
    method: 'POST',
    path: '/',
    headers: { 'User-Agent': 'aws-sdk-nodejs/2.166.0 darwin/v6.2.2' },
    body: '',
    endpoint:
    Endpoint {
        protocol: 'http:',
        host: '127.0.0.1:5000',
        port: 5000,
        hostname: '127.0.0.1',
        pathname: '/',
        path: '/',
        href: 'http://127.0.0.1:5000/',
        constructor: [Object] },
    region: undefined,
    _userAgent: 'aws-sdk-nodejs/2.166.0 darwin/v6.2.2' },
startTime: 2017-12-18T13:27:48.148Z,
response:
Response {
    request: [Circular],
    data: null,
    error: null,
    retryCount: 0,
    redirectCount: 0,
    httpResponse:
    HttpResponse {
        statusCode: undefined,
        headers: {},
        body: undefined,
        streaming: false,
        stream: null },
    maxRetries: 3,
    maxRedirects: 10 },
_asm:
AcceptorStateMachine {
    currentState: 'validate',
    states:
    { validate: [Object],
        build: [Object],
        afterBuild: [Object],
        sign: [Object],
        retry: [Object],
        afterRetry: [Object],
        send: [Object],
        validateResponse: [Object],
        extractError: [Object],
        extractData: [Object],
        restart: [Object],
        success: [Object],
        error: [Object],
        complete: [Object] } },
_haltHandlersOnError: false,
_events:
{ validate:
    [ [Object],
        [Function: VALIDATE_REGION],
        [Function: BUILD_IDEMPOTENCY_TOKENS],
        [Function: VALIDATE_PARAMETERS] ],
    afterBuild:
    [ [Object],
        [Function: SET_CONTENT_LENGTH],
        [Function: SET_HTTP_HOST] ],
    restart: [ [Function: RESTART] ],
    sign: [ [Object] ],
    validateResponse: [ [Function: VALIDATE_RESPONSE] ],
    send: [ [Object] ],
    httpHeaders: [ [Function: HTTP_HEADERS] ],
    httpData: [ [Function: HTTP_DATA] ],
    httpDone: [ [Function: HTTP_DONE] ],
    retry:
    [ [Function: FINALIZE_ERROR],
        [Function: INVALIDATE_CREDENTIALS],
        [Function: EXPIRED_SIGNATURE],
        [Function: CLOCK_SKEWED],
        [Function: REDIRECT],
        [Function: RETRY_CHECK] ],
    afterRetry: [ [Object] ],
    build: [ [Function: buildRequest], [Function: sanitizeUrl] ],
    extractData: [ [Function: extractData], [Function: extractRequestId] ],
    extractError: [ [Function: extractError], [Function: extractRequestId] ],
    httpError: [ [Function: ENOTFOUND_ERROR] ] },
emit: [Function: emit] }

正如您在上面的输出中所看到的,其中存在一个ENOTFOUND_ERROR错误。而且我在moto的控制台输出中找不到任何新的连接。

我开始moto的方式是moto_server route53

代码语言:javascript
复制
> moto_server route53
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

我的配置有什么问题?我想我的node.js代码有问题。我误解了endpoint的含义吗?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47870312

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档