felixge/node-mysql — Issue #173: Error: reconnection attempt failed before connection was fully set up
Author: opensource007
Created: 2012-03-06 02:26:46+00:00
State: open

arrtickers got around 200 values.

arrtickers closure pass in values into sym.

sym will pass in value to each function (running in async mode, each fn will start running)

mysql seems unable to handle multiple calls?

events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: reconnection attempt failed before connection was fully set up
at Socket. (/home/ubuntu/node/node_modules/mysql/lib/client.js:67:28)
at Socket.emit (events.js:64:17)
at TCP.onread (net.js:398:51)

arrtickers.forEach(function(value) {

var sym= value;

(function(sym) {

url2= "http://test2.com/quote.ashx?t="+sym+"&ty=c&ta=1&p=d&b=1";

request({ uri:url2 }, function (error, response, body) {

jsdom.env({
html: body,
scripts: [
jqlib
]
}, function (err, window) {

var $ = window.jQuery;
var data= $('body').html();
//some scrapping

var client2 = mysql.createClient({
user: 'root',
password: '123',
host: '127.0.0.1',
port: '3306'
});

client2.query('USE testtable');

sql= "update tbla SET a='"+a+"', b='"+b+"', c='"+c+"', d='"+d+"' where ticker='"+sym+"'";

client2.query(
sql, function(err, info){

if (err) {
throw err;
}
}
);

client2.end();

});
});

})(sym);

(function(sym) {

url= "http://test3.com/quote.ashx?t="+sym+"&ty=c&ta=1&p=d&b=1";

request({ uri:url3 }, function (error, response, body) {

jsdom.env({
html: body,
scripts: [
jqlib
]
}, function (err, window) {

var $ = window.jQuery;
var data= $('body').html();
//some scrapping

var client3 = mysql.createClient({
user: 'root',
password: '123',
host: '127.0.0.1',
port: '3306'
});

client3.query('USE testtable');

sql= "update tbla SET a='"+a+"', b='"+b+"', c='"+c+"', d='"+d+"' where ticker='"+sym+"'";

client3.query(
sql, function(err, info){

if (err) {
throw err;
}
}
);

client3.end();

});
});

})(sym);

(function(sym) {

url= "http://test4.com/quote.ashx?t="+sym+"&ty=c&ta=1&p=d&b=1";

request({ uri:url4 }, function (error, response, body) {

jsdom.env({
html: body,
scripts: [
jqlib
]
}, function (err, window) {

var $ = window.jQuery;
var data= $('body').html();
//some scrapping

var client4 = mysql.createClient({
user: 'root',
password: '123',
host: '127.0.0.1',
port: '3306'
});

client4.query('USE testtable');

sql= "update tbla SET a='"+a+"', b='"+b+"', c='"+c+"', d='"+d+"' where ticker='"+sym+"'";

client4.query(
sql, function(err, info){

if (err) {
throw err;
}
}
);

client4.end();

});
});

})(sym);

//same function repeat for test5.com, test6.com, test7.com, test8.com, test9.com

});