Skip to content

read ETIMEDOUT #558

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

Closed
gabrieledarrigo opened this issue Jul 29, 2013 · 9 comments
Closed

read ETIMEDOUT #558

gabrieledarrigo opened this issue Jul 29, 2013 · 9 comments

Comments

@gabrieledarrigo
Copy link

Ok,
I'm tryng to use node-mysql.
I'm parsing xml file in a remote folder every 5 minutes with a setInterval; if parsed content is valid then I proceed to insert data into the db.
After some time, when the script try to execute the insert query I receive this error:

Error: read ETIMEDOUT
    at errnoException (net.js:901:11)
    at TCP.onread (net.js:556:19)
    --------------------
    at Query.Sequence (/var/www/html/tmnews/node_modules/mysql/lib/protocol/sequences/Sequence.js:15:20)
    at new Query (/var/www/html/tmnews/node_modules/mysql/lib/protocol/sequences/Query.js:12:12)
    at Function.Connection.createQuery (/var/www/html/tmnews/node_modules/mysql/lib/Connection.js:48:10)
    at Connection.query (/var/www/html/tmnews/node_modules/mysql/lib/Connection.js:100:26)
    at getItemByIdFile (/var/www/html/tmnews/models/news.js:35:16)
    at /var/www/html/tmnews/service/parser.js:13:16
    at /var/www/html/tmnews/node_modules/parser/xml_parser.js:115:10
    at Object.oncomplete (fs.js:107:15)

So I've tryed to ping the server every ten minutes to prevent timeout but without success:

Error: read ETIMEDOUT
    at errnoException (net.js:901:11)
    at TCP.onread (net.js:556:19)
    --------------------
    at Ping.Sequence (/var/www/html/tmnews/node_modules/mysql/lib/protocol/sequences/Sequence.js:15:20)
    at new Ping (/var/www/html/tmnews/node_modules/mysql/lib/protocol/sequences/Ping.js:9:12)
    at Protocol.ping (/var/www/html/tmnews/node_modules/mysql/lib/protocol/Protocol.js:54:24)
    at Connection.ping (/var/www/html/tmnews/node_modules/mysql/lib/Connection.js:115:18)
    at null.<anonymous> (/var/www/html/tmnews/config/database.js:46:14)
    at wrapper [as _onTimeout] (timers.js:252:14)
    at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

This is my db configuration:

// Database configuration.
var mysql = require('mysql');

var config = {
    host      : 'localhost',
    user      : 'root',
    password  : 'root',
    database  : 'forum105',
    port      : 3306
};

var handler = function () {
    var connection = mysql.createConnection(config);

    connection.connect(function (error) {  
        if (error) {
            console.log(error);

            setTimeout(function () {
                console.log('Tryng to reconnect');
                handler();
            }, 5000);
        }
    });

    connection.on('error', function (error) {
        if(error.code === 'PROTOCOL_CONNECTION_LOST') { 
            handler();                     
        } else {                                      
            throw error;                                
        };
    });


    setInterval(function () {
        console.log('I am pinging');
        connection.ping();
    }, 2 * 60 * 60 * 1000);

    return connection;
};

module.exports = handler();

Configuration that i export and pass to my route and model in this form:

var connection = require('./config/database.js');
var models  = require('./models')(connection);
var routes  = require('./routes')(app, models);
var parser  = require('./service/parser.js')(app, models);

Am I doing something wrong? Prabably I miss something.
Any help is appreciated!

Gabriele

ps:tryed with pool too, but same things appen.

@seymar
Copy link

seymar commented Jul 30, 2013

I got the same error, seems to be this part in Sequence.js what is giving the error.

// Experimental: Long stack trace support
this._callSite = new Error;

@kai-koch
Copy link
Collaborator

Have you tried sending a query like "SELECT 1;" instead of ping?

@Redsandro
Copy link

Same problem. Receive ETIMEOUT after fake SELECT * FROM some_table LIMIT 1.
That or ping() seem to keep MySQL alive for up to 3 days.

@kai-koch
Copy link
Collaborator

For a twitter-stream client, I use one connection to store the tweets. Even when there are streaks, where there are no tweets coming in, the database connection is sound.
I use the following wrapper class to handle disconnects. Maybe that can help you with your problems, if you are not using the pool feature.
https://github.com/kai-koch/wut/blob/master/classes/DbWrapper.js

It runs for weeks now. That said I am not sure which version of node-mysql is running on the Server. Must be Alpha7 or 8.

@Egidius
Copy link

Egidius commented Jan 28, 2014

I've got the same problem. Anyone found a solution yet? Would be greatly appreciated!

@Redsandro
Copy link

No solution. I'd like to be able to catch this. bump
On Jan 28, 2014 7:13 PM, "Egidius" [email protected] wrote:

I've got the same problem. Anyone found a solution yet? Would be greatly
appreciated!

Reply to this email directly or view it on GitHubhttps://github.com//issues/558#issuecomment-33506620
.

@sidorares
Copy link
Member

Do you have some successful queries at the beginning and ETIMEOUT only after pause or no results at all and just error?

@Redsandro
Copy link

Sorry I thought I replied to #708. I had the problem discussed in this issue with no results at all and just error. Because I found no cure, I started using pooling which resolved the issue but now I have #708 which I'd like to catch.

@dougwilson
Copy link
Member

Closing this unless someone can provide some code I can run and reproduce the issue or a patch. All I have right now is speculation and I cannot determine what you are experiencing to move forward on anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants