error: Connection timed out after 1000ms For aws-sdk (amazonSES api)



  • I'm trying to develop nodebb-plugin-emailer-amazonses
    https://github.com/kenokabe/nodebb-plugin-emailer-amazonses

    Without nodeBB, I managed to success to send email along with amazonSES.
    The test code is
    https://github.com/kenokabe/nodebb-plugin-emailer-amazonses/blob/master/testapp.js
    with proper 'nodebb/node_modules/nodebb-plugin-emailer-amazonses/config.json'

    However, once implemented as nodebb plugin,
    error: Connection timed out after 1000ms
    occurs.

    In fact, commenting out

    var AWS = require('aws-sdk');
        AWS.config.loadFromPath('./config.json');
        var ses = new AWS.SES({apiVersion: '2010-12-01'});
    

    helps to succeed to install this plugin and launch nodeBB.
    So, somehow AWS.config process online fails.

    How does this happen? and how can I fix this?
    Please advice. Thanks!

    **Here's the log of ./nodebb dev
    **
    Launching NodeBB in "development" mode.
    ....
    ....
    info: [plugins] Loaded plugin: nodebb-plugin-emailer-amazonses
    ....
    ===========emailer-amazonses init============
    info: [sounds] Sounds OK
    info: [meta/js] Compilation complete
    info: [themes] Compiling templates
    info: [meta/css] Done.
    error: Connection timed out after 1000ms
    TimeoutError: Connection timed out after 1000ms
    at ClientRequest.<anonymous> (/home/ken/nodebb/node_modules/nodebb-plugin-emailer-amazonses/node_modules/aws-sdk/lib/http/node.js:51:34)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.EventEmitter.emit (events.js:92:17)
    at Socket.emitTimeout (http.js:1797:10)
    at Socket.g (events.js:180:16)
    at Socket.EventEmitter.emit (events.js:92:17)
    at Socket._onTimeout (net.js:326:8)
    at Timer.unrefTimeout [as ontimeout] (timers.js:418:13)
    info: [app] Shutdown (SIGTERM/SIGINT) Initialised.
    info: [app] Database connection closed.
    info: [app] Shutdown complete.


  • GNU/Linux Admin

    Hm, any chance you're not handling the err value when you make the call to aws using the aws-sdk module?

    Where does ./config.json point to, a config file in your plugin's root folder?



  • @julian said:

    Where does ./config.json point to, a config file in your plugin's root folder?

    Yes.
    ./config.json to be pointed by AWS.config.loadFromPath('./config.json'); in library.js
    is located on
    ~/nodebb/node_modules/nodebb-plugin-emailer-amazonses/config.json

    { "accessKeyId": "YOUR_AWS_API_ID",
      "secretAccessKey": "YOUR_SECRET",
      "region": "us-west-2" }
    

    Hm, any chance you're not handling the err value when you make the call to aws using the aws-sdk module?

    The current library.js is

    var winston = module.parent.require('winston'),
        Meta = module.parent.require('./meta'),
        Emailer = {},
        ses;
    
    Emailer.init = function (app, middleware, controllers)
    {
      console.log('===========emailer-amazonses init============');
      var AWS = require('aws-sdk');
      AWS.config.loadFromPath('./config.json');
      ses = new AWS.SES({
          apiVersion: '2010-12-01'
      });
    };
    //.............
    //...............
    

    Thanks.



  • PS.

    I hardcoded Credentials, then it works at least for the plugin initialisation and nodeBB ready.

    Hard-Coding Credentials

    So, probably
    AWS.config.loadFromPath('./config.json');
    This line somehow fails to import the credential info form the ./config.json = ( ~/nodebb/node_modules/nodebb-plugin-emailer-amazonses/config.json )

    Any idea how to fix this?



  • Ok, the problem is SOLVED.

    For nodeBB plugin, the current directory is not plugin(nodebb-plugin-foo/) but nodebb root.

    So, I placed emailer-amazonses-config.json in nodebb root dir.

    Then modified the pointer in the code of the plugin.

    Thanks.


  • Admin

    Maybe it would be better to keep that config in the plugin's directory and then modify this line to:

    AWS.config.loadFromPath('./node_modules/nodebb-plugin-emailer-amazonses/config.json');

    ?

    Also, am looking forward to you releasing this plugin 🙂


Log in to reply
 

Suggested Topics

| |