denodrivers / postgres

PostgreSQL driver for Deno
https://denodrivers.github.io/postgres
MIT License
599 stars 96 forks source link

Error: Unknown auth message code 1375731712 #242

Open Dreamkarifha9 opened 3 years ago

Dreamkarifha9 commented 3 years ago

Error: Unknown auth message code 1375731712 at Connection.handleAuth (connection.ts:216:15) at Connection.startup (connection.ts:170:16) at async Client.connect (client.ts:163:5) at async RegisteractModel.findfristpage (Registeract_test.ts:104:7) at async getFristpage (RegisterController_test.ts:19:19) at async dispatch (middleware.ts:39:7) at async authMiddleware (authMiddleware.ts:17:7) at async dispatch (middleware.ts:39:7) at async dispatch (middleware.ts:39:7) at async dispatch (middleware.ts:39:7)

Dreamkarifha9 commented 3 years ago

Another One

PartialReadError: Encountered UnexpectedEof, data only partially read at BufReader.readFull (bufio.ts:183:19) at async Connection.readMessage (connection.ts:120:5) at async Connection._simpleQuery (connection.ts:313:11) at async Connection.query (connection.ts:589:16) at async RegisteractModel.findfristpage (Registeract_test.ts:115:22) at async getFristpage (RegisterController_test.ts:19:19) at async dispatch (middleware.ts:39:7) at async authMiddleware (authMiddleware.ts:17:7) at async dispatch (middleware.ts:39:7) at async dispatch (middleware.ts:39:7)

seilon-zhang commented 3 years ago

I made the same mistake const dbPool = new Pool({ user: "postgres", password: "123456", database: "deno", hostname: "192.168.18.200", port: 5432, }, POOL_CONNECTIONS);

error: Uncaught (in promise) Error: Unknown auth message code 10 throw new Error(Unknown auth message code ${code}); ^ at Connection.handleAuth (connection.ts:216:15) at Connection.startup (connection.ts:170:16) at async Pool._createConnection (pool.ts:38:5) at async pool.ts:67:7 at async Promise.all (index 3) at async Pool._startup (pool.ts:69:25) at async Pool.connect (pool.ts:90:5) at async runQueryObject (database.ts:14:30) at async app.ts:6:1

Soremwar commented 3 years ago

Hi there @Dreamkarifha9 and @seilon-zhang

Could you please provide information about your Postgres server setup? Specifically what authentication method are you using and Postgres version,

The next thing in the todo list is to provide other connection methods different than standard user password authentication

SSL/TLS for example aren't supported right now, but knowing what other authentication methods could be supported in the meanwhile will be of great help

seilon-zhang commented 3 years ago

The database version used is 13, which is the default setting, and no other changes have been made

seilon-zhang commented 3 years ago

@Soremwar I've browsed your previous questions and answers, which should be about the verification of the screen-sha-256

Soremwar commented 3 years ago

@seilon-zhang You are right. I will be adding support for this authentication method in the following days

@Dreamkarifha9 I just released a new version that parses the Postgres error messages instead of just showing the error code. Could you pleased update adn tell me what the new error tells you

Dreamkarifha9 commented 3 years ago

@Soremwar

I have updated to the last version. 0.7.0

Error Another

Error: Unknown auth message code 1375731712 at Connection.handleAuth (connection.ts:216:15) at Connection.startup (connection.ts:170:16) at async Client.connect (client.ts:163:5) at async RegisteractModel.findfristpage (Registeract_test.ts:104:7) at async getFristpage (RegisterController_test.ts:19:19) at async dispatch (middleware.ts:39:7) at async authMiddleware (authMiddleware.ts:17:7) at async dispatch (middleware.ts:39:7) at async dispatch (middleware.ts:39:7) at async dispatch (middleware.ts:39:7)

My setting Config.ts

const dbConfigsetup: ConnectionOptions = { user: "postgres", password: "", database: "", hostname: "", port: 5432, }; export const config: Config = { dbConfigsetup, jwtSecret: Deno.env.get("JWT_SECRET")!, };

My setting Controller

export async function getFristpage(ctx: RouterContext) { try { const { response } = ctx; const posts = await Registeract.findfristpage(); response.status = 200; response.body = posts; } catch (error) { console.log(error); throw error; } }

My setting modules

class RegisteractModel { private dbClient: Client;

constructor(dbClient: Client) { this.dbClient = dbClient; }

async findfristpage(): Promise { try { await this.dbClient.connect(); const text = SELECT machineactivitydetails.id, machineactivitydetails.actcode, machineactivitydetails.description as actdescription, machineactivitydetails.duratypeid, machineactivitydetails.is_active, machineactivitydetails.update_date, machinedetails.idmachine, machineactivitydetails.update_by, duratype.description, duratype.dura_day, machinedetails.name, machinedetails.orders, machineactivitydetails.machinegroupid, machinegroup.name as machinegroupname, machineactivitydetails.machinedetailsid, machineactivitydetails.standard FROM machineactivity AS machineactivitydetails LEFT JOIN duratype on duratype.id = machineactivitydetails.duratypeid LEFT JOIN machinedetails on machinedetails.id = machineactivitydetails.machinedetailsid LEFT JOIN machinegroup on machinegroup.id = machineactivitydetails.machinegroupid ORDER BY machineactivitydetails.id DESC LIMIT 10 ;; const result = await this.dbClient.queryObject({ text, }); await this.dbClient.end(); return result.rows; } catch (error) { console.log(error); throw error; } }

}

Soremwar commented 3 years ago

@Dreamkarifha9 The patch to check the error was released on 0.7.1 :/

Dreamkarifha9 commented 3 years ago

@Soremwar

update on 0.7.1 error

Error: Unknown auth message code 1375731712 at Connection.handleAuth (connection.ts:233:15) at Connection.startup (connection.ts:171:16) at async Client.connect (client.ts:163:5) at async RegisteractModel.findfristpage (Registeract_test.ts:104:7) at async getFristpage (RegisterController_test.ts:19:19) at async dispatch (middleware.ts:39:7) at async authMiddleware (authMiddleware.ts:17:7) at async dispatch (middleware.ts:39:7) at async dispatch (middleware.ts:39:7) at async dispatch (middleware.ts:39:7)

Another one error BadResource: Bad resource ID
at unwrapResponse (deno:cli/rt/10_dispatch_minimal.js:59:13) at sendAsync (deno:cli/rt/10_dispatch_minimal.js:98:12) at async read (deno:cli/rt/12_io.js:99:19) at async BufReader.read (bufio.ts:146:12) at async BufReader.readFull (bufio.ts:178:20) at async Connection.readMessage (connection.ts:120:5) at async Connection.startup (connection.ts:170:11) at async Client.connect (client.ts:163:5) at async RegisteractModel.findfristpage (Registeract_test.ts:104:7) at async getFristpage (RegisterController_test.ts:19:19)

Soremwar commented 3 years ago

@Dreamkarifha9 Ok, so it doesn't seem to be a connection error

What method are you using to authenticate with your database? Plain password? SSL? TLS?

Dreamkarifha9 commented 3 years ago

@Soremwar

I use setup

const dbConfigsetup: ConnectionOptions = { user: "postgres", password: "200711", database: "", hostname: "", port: 5432, }; export const config: Config = { dbConfigsetup, }; export { database, dbconfig };

How am i supposed To do that?

Soremwar commented 3 years ago

No, I mean how is your database configured. Or if you are using a database provided as a service (Amazon, Azure, etc) which one are you using and what are your settings?

I'm trying to understand what the driver is lacking in order to connect to your database

Dreamkarifha9 commented 3 years ago

@Soremwar

I use postgresql
And i use Docker on windows serve

Soremwar commented 3 years ago

Did you configured the docker image yourself?

Also can you come to the discord server? It's kinda annoying trying to figure out the issue this way

Dreamkarifha9 commented 3 years ago

Yes, I can ask your discord server

Soremwar commented 3 years ago

I'm in the postgres channel, the link is in the README

Dreamkarifha9 commented 3 years ago

Ok

EliSauder commented 3 years ago

@Soremwar Not sure what the status of this issue is, but here is an observation I made: The binary representation of 1375731712 is: 1010010000000000000000000000000 The first byte (byte1) is: 1010010 (82, 0x52) which happens to be the ASCII character 'R'


It is possible that the error is for a Routine error. As defined in section 52.8 of the PostgreSQL 13 manual, the ErrorResponse and NoticeResponse messages can contain different fields, one of which is the R field. The description is as follows: "Routine: the name of the source-code routine reporting the error."


Another possibility is that the error code might be one of the postgres Logical Replication Message Formats as defined in section 52.9 of the PostgreSQL 13 manual. The Byte1('R') is for the Relation Logical Replication Message Format.

iugo commented 2 years ago

Same error:

PartialReadError: Encountered UnexpectedEof, data only partially read
    at BufReader.readFull (https://deno.land/std@0.114.0/io/buffer.ts:420:19)
    at async Connection.#readMessage (https://deno.land/x/postgres@v0.15.0/connection/connection.ts:168:5)
    at async Connection.#preparedQuery (https://deno.land/x/postgres@v0.15.0/connection/connection.ts:904:25)
    at async Connection.query (https://deno.land/x/postgres@v0.15.0/connection/connection.ts:930:16)
SpiritOfSpirt commented 2 years ago

I have same error on version 0.16.1

Error: Unknown auth message code 1375731712
    at Connection.#authenticate (https://deno.land/x/postgres@v0.16.1/connection/connection.ts:550:15)
    at Connection.#startup (https://deno.land/x/postgres@v0.16.1/connection/connection.ts:412:31)
    at async Connection.startup (https://deno.land/x/postgres@v0.16.1/connection/connection.ts:491:11)
    at async Connection.query (https://deno.land/x/postgres@v0.16.1/connection/connection.ts:943:7)
    at async Client.#executeQuery (https://deno.land/x/postgres@v0.16.1/client.ts:245:12)
    at async Client.queryObject (https://deno.land/x/postgres@v0.16.1/client.ts:433:12)

For

config = {
  hostname: 'localhost',
  port: 5432,
  database: 'myDb'
  user: <user>,
  password: <password>,
}

new Client({...config, tls: { enabled: false }});

Without tls: { enabled: false } it gives other error

Error: Could not check if server accepts SSL connections, server responded with: 69
    at Connection.#serverAcceptsTLS (https://deno.land/x/postgres@v0.16.1/connection/connection.ts:200:15)
    at async Connection.#startup (https://deno.land/x/postgres@v0.16.1/connection/connection.ts:344:29)
    at async Connection.startup (https://deno.land/x/postgres@v0.16.1/connection/connection.ts:491:11)
    at async Connection.query (https://deno.land/x/postgres@v0.16.1/connection/connection.ts:943:7)
    at async Client.#executeQuery (https://deno.land/x/postgres@v0.16.1/client.ts:245:12)
    at async Client.queryObject (https://deno.land/x/postgres@v0.16.1/client.ts:433:12)

It happens when i send two query in very short time to the database.

Aha after asking right person I've understand that don't use db in right way and should use Lazy pools