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

Connection Using Unix Sockets getting Error : getaddrinfo ENOENT #6547

Closed
sdogruyol opened this issue Aug 9, 2013 · 9 comments
Closed

Connection Using Unix Sockets getting Error : getaddrinfo ENOENT #6547

sdogruyol opened this issue Aug 9, 2013 · 9 comments
Labels
mysql Issue only occurs when using MySQL orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc.

Comments

@sdogruyol
Copy link

I'm aware that sails-mysql uses node-mysql in the background. But i still can't seem to use the mysql socket to connect. Is there an option for this ?

What i'm trying to do is

adapter: 'sails-mysql',
user: 'root',
password: '',
database: 'benchmark_db',
socketPath : '/tmp/mysql.sock'

I can use this socket via other apps (e.g a Rails app, a custom Node app ) and can also telnet localhost 3306.

Any suggestions?

@particlebanana
Copy link
Contributor

We currently don't support a socketPath config option. I'm not against it, just hasn't come up yet. For the time being you can just set host: localhost.

I'll mark this as a feature request. I don't know when I will get a chance to look at it but if anyone wants to do a PR it'd be welcome!

@sdogruyol
Copy link
Author

Hey there,

Thanks for the quick response. The problem is that the db that i'm using is not allowing network connections and only be usable by socket. That's why i can't connect to it .

Isn't sails-mysql using node-mysql in the background. As i remember it's available in the node-mysql settings.

@particlebanana
Copy link
Contributor

I just added it to the marshalConfig function 16ecaf3e99e73728294650edb2ac76f02e163b76 so it should get passed down to node-mysql.

Let me know if that works and if so I can do an npm push.

@sdogruyol
Copy link
Author

Seems like not working. Is there something that i can do ?

@particlebanana
Copy link
Contributor

I just tried and was able to connect over a socket. What's the error you get when it fails? Also you tried using a clone of the repo correct?

@sdogruyol
Copy link
Author

Actually i haven't clone the whole repo just added the diff code.

The error i'm getting is this.

Error spawning mySQL connection:
{ [Error: getaddrinfo ENOENT]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
fatal: true }

domain.js:66
throw er;
^
TypeError: Cannot call method 'end' of undefined

@particlebanana
Copy link
Contributor

hmm as long as that socketPath value is getting into either of these places it's just using node-mysql to create a connection:

with pooling: https://github.com/balderdashy/sails-mysql/blob/master/lib/adapter.js#L66
without pooling: https://github.com/balderdashy/sails-mysql/blob/master/lib/adapter.js#L504

Also I just want to make sure your adapter config is correct. If you are using it from config/adapters.js it should look like this:

module.exports.adapters = {
    'default': 'mysql',

    mysql: {
        module: 'sails-mysql',
        user: 'username',
        password: 'password',
        database: 'databaseName',
        socketPath: '/tmp/mysql.sock'
    }
}

And if you are defining the connection directly on a model it will look like:

module.exports = {

    adapter: 'mysql',

    config: {
        user: 'username',
        password: 'password',
        database: 'databaseName',
        socketPath: '/tmp/mysql.sock'
    },

    attributes: {

    }
}

@sdogruyol
Copy link
Author

Cheers mate ! I was trying to use the adapter without defining a config object thus leading to that problem.

Thanks for the help now it's working perfectly. 👍

@particlebanana
Copy link
Contributor

This is pushed to NPM now at version 0.9.2

@johnabrams7 johnabrams7 transferred this issue from balderdashy/sails-mysql Jun 4, 2019
@johnabrams7 johnabrams7 added mysql Issue only occurs when using MySQL orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. labels Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mysql Issue only occurs when using MySQL orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc.
Development

No branches or pull requests

3 participants