Error: Unrecognized message code 91
I am using this library via SequelizeJS. It has worked very well until today when I began to investigate the possibility of using database migrations.
I get this error using this library:
Error: Unrecognized message code 91
I have tried to find what message code 91 means, but I have not found anything yet. I believe its possible that Sequelize is transmitting something bad to the postgres server, and the response is the annoying 91.
Can anyone find any information what code 91 means?
pg library version: 1.1.2 postgres server: 9.1.9 dist: ubuntu 3.8.0-19-generic
Can you provide an executable sample of code to reproduce this?
I'm sorry, but If I don't have code to reproduce there's really no way we can work on fixing this issue.
HI, I am sorry for not answering earlier. I've had a busy period, but I will look into this the following days. I will try to produce some code and reply to you as soon as possible.
I looked how Sequelize uses this library and made a short script that describes the issue.
var pg = require('pg');
var client = new pg.Client("tcp://test:[email protected]:3306/test");
client.connect(function(err, client) {
console.log(err);
console.log(client);
});
Runtime: (Version 2.0.0 of pg)
$ nodejs app.js
/usr/lib/node_modules/pg/lib/connection.js:428
throw new Error("Unrecognized message code " + id);
^
Error: Unrecognized message code 91
at Connection.parseMessage (/usr/lib/node_modules/pg/lib/connection.js:428:11)
at Socket.<anonymous> (/usr/lib/node_modules/pg/lib/connection.js:97:20)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:736:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:408:10)
at emitReadable (_stream_readable.js:404:5)
at readableAddChunk (_stream_readable.js:165:9)
at Socket.Readable.push (_stream_readable.js:127:10)
at TCP.onread (net.js:526:21)
Notice: I have tried with both correct and incorrect login credentials. But code 91 is given in both cases.
I appreciate the detailed response, and I'm sorry you're having that issue! The script snippet you posted should definitely work. Unrecognized message code 91 means the backend sent [ as the message code, which isn't in the postgres protocol at all so something weird is going on on your end. Can you connect to postgres with psql? Can you connect with the native bindings instead of the JavaScript ones? Are you running any tcp proxies or pg-bouncer or anything? Have you tried connecting to another instance of postgres other than the one returning this code? This has cropped up in the past & it turned out to be a configuration issue with the user's database. Have you looked through passed issues about this?
It's really hard to debug this one because it comes down to a "works on my machine" except in this case it works on almost everyone's machine except yours. :(
I ran into this issue as well, and it appears when I don't specify the port. I expect sequelize-postgres to be defaulting to 5432, but I have a hunch that it isn't correctly. The connection string in the pasted sample snippet has a port of 3306 which is the default MySQL port, Postgres defaults to 5432. @ach are you running Pg on the MySQL port?
Additionally, if I specify the 'protocol' as null then I get a password authentication failure, though was hoping that would switch to unix socket connection.
Did you ever get this figured out? Feel free to reopen if its still causing you problems. Otherwise I'm going to assume you found a fix.