can not connect by dbeaver and datagrip.
Closed this issue · 8 comments
when connect this server by datagrip or dbeaver, there is a error mean server version is not existed
so that i tried to add server version field:
// ParameterStatus for server_version
const serverVersionParam = new GrowableOffsetBuffer();
serverVersionParam.write("S");
serverVersionParam.write("server_version");
serverVersionParam.write("15.0");
// ReadyForQuery
const readyForQuery = new GrowableOffsetBuffer();
readyForQuery.write("Z");
readyForQuery.writeUint32BE(5);
readyForQuery.write("I");
return Buffer.concat([
authOk.toBuffer(),
backendKeyData.toBuffer(),
serverVersionParam.toBuffer(),
readyForQuery.toBuffer(),
]);
i have no idea for this. sigh...
ParameterStatus
requires uint32
on its second position to indicate length of the message - https://www.postgresql.org/docs/current/protocol-message-formats.html#PROTOCOL-MESSAGE-FORMATS-PARAMETERSTATUS so the code should say something like
// ParameterStatus
const param = "server_version15.0";
const parameterStatus = new GrowableOffsetBuffer();
parameterStatus.write("S");
parameterStatus.writeUint32BE(4 + param.length);
parameterStatus.write(param);
From my quick test this in itself doesn't solve the issue though, and I don't have much spare time to debug now (probably will in the future though).
All those params should be ignored by the frontend if missing/malformed anyway, so it's also kind of issue with DBeaver itself as well.
https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-ASYNC
Accordingly, a frontend should simply ignore ParameterStatus for parameters that it does not understand or care about.
https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-START-UP
This message informs the frontend about the current (initial) setting of backend parameters, such as client_encoding or DateStyle. The frontend can ignore this message, or record the settings for its future use; see Section 55.2.7 for more details. The frontend should not respond to this message, but should continue listening for a ReadyForQuery message.
Do you have Datagrip error message by any chance? As is right now + when adding parameter above?
@kamilogorek i have tried this code
function createStartupMessageReponse(): Buffer {
// AuthenticationOk
const authOk = new GrowableOffsetBuffer();
authOk.write("R");
authOk.writeUint32BE(8);
authOk.writeUint32BE(0);
// BackendKeyData
const backendKeyData = new GrowableOffsetBuffer();
backendKeyData.write("K");
backendKeyData.writeUint32BE(12);
backendKeyData.writeUint32BE(1);
backendKeyData.writeUint32BE(2);
// ParameterStatus
const param = "server_version15.0";
const parameterStatus = new GrowableOffsetBuffer();
parameterStatus.write("S");
parameterStatus.writeUint32BE(4 + param.length);
parameterStatus.write(param);
// ReadyForQuery
const readyForQuery = new GrowableOffsetBuffer();
readyForQuery.write("Z");
readyForQuery.writeUint32BE(5);
readyForQuery.write("I");
return Buffer.concat([
authOk.toBuffer(),
backendKeyData.toBuffer(),
parameterStatus.toBuffer(),
readyForQuery.toBuffer(),
]);
}
on datagrip it still the same error. can not establish session
protocol error, session setup failed
Fixed in https://github.com/kamilogorek/pglite-server/releases/tag/v0.1.3
I forgot that strings in this protocol are null-terminated :)
Thanks for your work!!!
Thanks for your work!!!
Failed
Copy Search Error Troubleshooting
DBMS: PostgreSQL (ver. pglite) Case sensitivity: plain=lower, delimited=exact Driver: PostgreSQL JDBC Driver (ver. 42.6.0, JDBC4.2)
Ping: 9 ms [0A000] ClientInfo property not supported.
but on datagrip it still can not connect. anyway it's enough Thank you~
There's a chance that datagrip requires a valid version instead of mocked value. If you want to play around locally, just swap pglite
string with 15.0.0
or some other value and see if that works for you.
i have tried replace version pglite
to 15.0.0 and datagrid actually can be connected. but can't display any database or schema.
showing this error
could not open directory "/usr/share/zon. Cannot open cursor: the statement was not executed or it has not returned curs
but dbeaver did works. not a big problem