Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7676435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:11:57+00:00 2026-05-31T17:11:57+00:00

I am using: node-mysql arrtickers got around 200 values. arrtickers closure pass in values

  • 0

I am using: node-mysql

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 on its own without waiting for the previous fn to complete)

problem here is 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.<anonymous> (/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



        });

Below is portion of the code from client.js (part of node-mysql)
I don’t really understand how the whole process get linked together, any idea guys?

Client.prototype._connect = function() {
  this.destroy();

  var socket = this._socket = new Socket();
  var parser = this._parser = new Parser();
  var self = this;

  socket
    .on('error', this._connectionErrorHandler())
    .on('data', parser.write.bind(parser))
    .on('end', function() {
      if (self.ending) {
        // @todo destroy()?
        self.connected = false;
        self.ending = false;

        if (self._queue.length) {
          self._connect();
        }

        return;
      }

      if (!self.connected) {
        this.emit('error', new Error('reconnection attempt failed before connection was fully set up'));
        return;
      }

      self._connect();
    })
    .connect(this.port, this.host);

  parser.on('packet', this._handlePacket.bind(this));
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:11:58+00:00Added an answer on May 31, 2026 at 5:11 pm

    You can use node-mysql-queues module, which is a wrapper for the current module you are using. Here is the information: https://github.com/bminer/node-mysql-queues

    Sample Multi-Query from their page:

    var q = client.createQueue();
    q.query(...); 
    q.query(...);
    q.execute();
    
    client.query(...); //Will not execute until all queued queries (and their callbacks) completed.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tree structure in MySQL using a parent_id field for each node.
How can I just obtain the string value of a Xml node using xpath
I'm using the Node.JS node-mysql module. One column has a BLOB type and want
I have a node.js app using node-mysql to query a MySQL database. Problem: It
I am loading data from the database using mysql drivers for node.js. https://github.com/felixge/node-mysql I
I have a MySQL database holding hierarchical data using the Closure Table method. A
I am using node-mysql module ( https://github.com/felixge/node-mysql ) OR ( http://utahjs.com/2010/09/22/nodejs-and-mysql-introduction/ ) . Is
I am using nodejs and the node-mysql driver. I find myself doing repetitive boiler
I'm trying to connect to MySQL database from node.js using db-mysql library. Everything works
I am using node-mysql driver for a node.js app. Instead of having to set-up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.