sidorares / sidorares/node-mysql2

insecureAuth support (was: bad handshake)

Open
#30 35 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement mysqljs/mysql incompatibilities
Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

Output: 'Query error: Bad handshake'

Server: MySQL server 5.0.95 (Linux)

Code:

var mysql = require('mysql2');

var config = {
  host: '127.0.0.1',
  user: 'user',
  password: 'password',
  database: 'database',
  typeCast: false,
  supportBigNumbers: true,
  bigNumberStrings: true,
  insecureAuth: true
}, c;

function doConnect() {
  c = mysql.createConnection(config);
  c.connect(function(err) {
    console.log('Client connected');
  });
  c.on('error', function(err) {
    if (err.code === 'PROTOCOL_CONNECTION_LOST') {
      console.log('Disconnected -- reconnecting ...');
      doConnect();
    } else
      throw err;
  });
}

function doQuery() {
  var count = 0;

  console.log('starting query ...');

  c.query('select * from foo')
   .on('error', function(err) {
     console.log('Query error: ' + err);
   })
   .on('result', function(row) {
     ++count;
   })
   .once('end', function(info) {
     console.log('Query finished successfully');
     console.log(count + ' rows');
   });
}

doConnect();
doQuery();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the connection and authentication handling for the insecureAuth option, then reproduce the Bad handshake against MySQL 5.0.95 with the provided configuration. Done means a connection using insecureAuth no longer reports that handshake error, with coverage for the supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mysql, node.js
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.