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

Trying to connect to sql database got an error #19

Open
riteshkarwa opened this issue Jan 24, 2020 · 0 comments
Open

Trying to connect to sql database got an error #19

riteshkarwa opened this issue Jan 24, 2020 · 0 comments

Comments

@riteshkarwa
Copy link

riteshkarwa commented Jan 24, 2020

link to gihub repo https://github.com/riteshkarwa/my-repository

created a connect.js file the code live in there

var connection = mysql.createConnection({
          host : "remotemysql.com",
          user: "",
          database: "",
          password: ""
          //port:"3306"
        });
    }

exports.handler = function (event, context, callback) {
    context.callbackWaitsForEmptyEventLoop =false;
    connection.connect(function(err) {
      if (err) {
        console.error('Error connecting: ' + err.stack);
      }
      console.log('Connected as thread id: ' + connection.threadId);
    });

var results=[];
//SQL Query > Select Data

return new Promise((resolve, reject) => {
  const readTable = `SELECT * FROM num_of_likes`;
  connection.query(readTable, (err, results, fields) => {
    if (err) {
     reject(err);
    } else {
      resolve({statusCode: 200, body: {results}});
    }
  });
});

*Lambda server is listening on 9000
Request from ::1: GET /connect
Error connecting: Error: Received packet in the wrong sequence.
at A._parsePacket (/Users/riteshkarwa/netlify/functions/connect.js:1:93387)
at A._parsePacket (/Users/riteshkarwa/netlify/functions/connect.js:1:102113)
at A.write (/Users/riteshkarwa/netlify/functions/connect.js:1:96341)
at A.write (/Users/riteshkarwa/netlify/functions/connect.js:1:89855)
at Socket. (/Users/riteshkarwa/netlify/functions/connect.js:1:7771)
at Socket. (/Users/riteshkarwa/netlify/functions/connect.js:1:6835)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead (internal/stream_base_commons.js:182:23)

at A._enqueue (/Users/riteshkarwa/netlify/functions/connect.js:1:91233)
at A.handshake (/Users/riteshkarwa/netlify/functions/connect.js:1:89978)
at o.connect (/Users/riteshkarwa/netlify/functions/connect.js:1:8643)
at Object.E.handler (/Users/riteshkarwa/netlify/functions/connect.js:1:238235)
at /Users/riteshkarwa/netlify/node_modules/netlify-lambda/lib/serve.js:144:27
at Layer.handle [as handle_request] (/Users/riteshkarwa/netlify/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:137:13)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at Route.dispatch (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/riteshkarwa/netlify/node_modules/express/lib/router/layer.js:95:5)
at /Users/riteshkarwa/netlify/node_modules/express/lib/router/index.js:281:22
Connected as thread id: 15223054
Response with status 500 in 2105 ms.
Error during invocation: Error: Received packet in the wrong sequence.
at A._parsePacket (/Users/riteshkarwa/netlify/functions/connect.js:1:93387)
at A._parsePacket (/Users/riteshkarwa/netlify/functions/connect.js:1:102113)
at A.write (/Users/riteshkarwa/netlify/functions/connect.js:1:96341)
at A.write (/Users/riteshkarwa/netlify/functions/connect.js:1:89855)
at Socket. (/Users/riteshkarwa/netlify/functions/connect.js:1:7771)
at Socket. (/Users/riteshkarwa/netlify/functions/connect.js:1:6835)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead (internal/stream_base_commons.js:182:23)

at A._enqueue (/Users/riteshkarwa/netlify/functions/connect.js:1:91233)
at A.handshake (/Users/riteshkarwa/netlify/functions/connect.js:1:89978)
at o.connect (/Users/riteshkarwa/netlify/functions/connect.js:1:8643)
at Object.E.handler (/Users/riteshkarwa/netlify/functions/connect.js:1:238235)
at /Users/riteshkarwa/netlify/node_modules/netlify-lambda/lib/serve.js:144:27
at Layer.handle [as handle_request] (/Users/riteshkarwa/netlify/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:137:13)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at next (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:131:14)
at Route.dispatch (/Users/riteshkarwa/netlify/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/riteshkarwa/netlify/node_modules/express/lib/router/layer.js:95:5)
at /Users/riteshkarwa/netlify/node_modules/express/lib/router/index.js:281:22 {
code: ‘PROTOCOL_INCORRECT_PACKET_SEQUENCE’,
fatal: true

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

1 participant