开发者

Node-MySQL (felixge) connection problems

I'm run开发者_运维问答ning Node.js 4.1 with Node-Mysql on an Ubuntu 10.04 LTS VM. I'm having some weird problems, however, and I'm not sure what's causing it.

I occasionally cannot connect to the database, and other times it works fine. When I can't connect I see the connection popup in the connections on the mysql side, with the user as "unauthenticated" and the state as "reading from net" but it goes away after a few seconds. The .connect() callback never fires and I'm not sure where to go from here.

I am using port forwarding from the host machine to the vm, for 22 for SSH and 80 for http requests, but other than that everything is normal. The host on mysql shows up as the host machine, and not the VM, although it does that even for successful connects.

Not sure of the significance but the connection holds in TIME_WAIT on the VM, and the local address:port is different than what MySQL has, for successfull connections as well.


Are you using the latest version (0.9.2)? If you are, you no longer use .connect().

https://github.com/felixge/node-mysql/wiki/Upgrading-to-0.9.2+

So instead of:

var client = require('mysql').Client();
client.connect();
client.query('SELECT 1', function() {
});

You now have to write:

var client = require('mysql').createClient();
client.query('SELECT 1', function() {
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜