Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: read ECONNRESET #10

Closed
tloyau opened this issue Dec 1, 2016 · 6 comments
Closed

Error: read ECONNRESET #10

tloyau opened this issue Dec 1, 2016 · 6 comments
Assignees

Comments

@tloyau
Copy link

tloyau commented Dec 1, 2016

Hello, I have an error with my bot but I don't understand why it is happened

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at exports._errnoException (util.js:907:11)
    at TCP.onread (net.js:557:26)

Process exited with code: 1
@nmarus
Copy link
Member

nmarus commented Dec 1, 2016

ECONNRESET means the other side of the TCP conversation abruptly closed its end of the connection. That particular error is typically generated from either the native node js http(s) libraries referenced in one of the dependent modules. It is not generated by Flint directly. If it is happening when Flint is requesting a URL from the spark API, it will likely be either be something with your connection, or the Spark API itself is having some issues. If it was a malformed request from Flint or your implementation of Flint, the error should be different.

You can try to enable the debugs by starting your app with DEBUG=* node myapp.js to see if you get more info on where it is happening in the flow.

If you can share an example code where it is happening I can verify if it is related to Flint's code in any way. Feel free to email me at nmarus@gmail.com if you do not wish to share src here.

@nmarus nmarus self-assigned this Dec 1, 2016
@tloyau
Copy link
Author

tloyau commented Dec 1, 2016

Here is the code

var Flint = require('node-flint');
var webhook = require('node-flint/webhook');
var Restify = require('restify');
var request = require('request');

var server = Restify.createServer();
server.use(Restify.bodyParser());

// flint options
var config = {
    webhookUrl: 'https://demo-bot-tloyau.c9users.io:' + process.env.PORT + '/flint',
    token: '(secret)',
    port: process.env.PORT,
    minTime: 1
};

// init flint
var flint = new Flint(config);
flint.start();

// enable the Spark markdown in the message sent by the bot
flint.messageFormat = 'markdown';

// say hello
flint.hears("bonjour", function(bot, trigger) {
    flint.debug(flint);
    bot.say('Bonjour %s !', trigger.personDisplayName);
});

// say call
flint.hears("call", function(bot, trigger) {
    bot.say("J'appelle %s...", trigger.personDisplayName);
    
    // token from the script of demo-bot in Tropo 
    var tropoToken= '507a7848414f625a6a5452754a424b626d486a5a77586e536456536c58756f54786f554a677a7745494f556c';
    
    // uri of the user who sent the message
    var uri = trigger.personUsername + '@cisco.call.ciscospark.com';
    
    // the request to launch the Tropo's script (demo-bot) with the parameters : token, uri, name of the user
    var stringRequest = "https://api.tropo.eu/1.0/sessions?action=create&token=" + tropoToken + "&uri=" + uri + "&name=" + trigger.personDisplayName;
    
    // launch the request    
    request
        .get(stringRequest)
        .on('error', function(err) {
            flint.debug(err);
    });
    
    // log for test
    flint.debug('demo-bot appelle %s', trigger.personDisplayName);
});

// show how to interact with the demo-bot
flint.hears('help', function(bot, trigger) {
    bot.say("Je suis le Demo-Bot, je sais répondre à deux commandes :" +
    "\n\n- bonjour **(je te saluerai en retour)**\n\n- call **(je t'appelerai sur Spark)**");
})

// message sent if demo-bot can't interpret command sent by user
flint.hears(/.*/, function(bot, trigger) {
    bot.say("Je vous prie de m'excuser mais je ne comprends pas ce que vous dites.\n\nUtilisez la commande **_help_** afin de connaître les commandes auxquelles je peux répondre." +
    "\n\nPS : n'oubliez pas de me mentionner si vous êtes dans une room avec plusieurs personnes, comme ceci :\n- @demo-bot help");
}, 20);

flint.hears(/.*/, function(bot, trigger) {
    flint.debug(trigger);
}, 19);

// show in the console the messages sent by users of the room
flint.on('message', function(bot, trigger, id) {
   flint.debug('"%s" said "%s" in room "%s"', trigger.personEmail, trigger.text, trigger.roomTitle); 
});

// show in the console the number of rooms where bot is deployed
flint.on('initialized', function(){
   flint.debug('initialized %s rooms', flint.bots.length); 
});

// define restify path for incoming webhooks
server.post('/flint', webhook(flint));

// start restify server
server.listen(config.port, function () {
  flint.debug('Flint listening on port %s', config.port);
});

// gracefully shutdown (ctrl-c)
process.on('SIGINT', function() {
  flint.debug('stoppping...');
  server.close();
  flint.stop().then(function() {
      process.exit();
  });
});

@tloyau
Copy link
Author

tloyau commented Dec 7, 2016

Any idea ? :/

@nmarus
Copy link
Member

nmarus commented Dec 8, 2016

At what point do get that error? On running the app? or when running a particular "hears" command?

@tloyau
Copy link
Author

tloyau commented Dec 8, 2016

This error appears randomly, sometimes, it appears when I start my bot, but more often, it appears when I don't speak to bot while twenty minutes approximately. I have the feeling that cloud9 turn the bot in idle.

@tloyau
Copy link
Author

tloyau commented Jan 5, 2017

You can close this issue, this error no longer appears.

@nmarus nmarus closed this as completed Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants