Title
#users-public
b

Bartosz

09/12/2022, 6:56 AM
Hello guys. I've problem with nodejs-questdb-client. Description in thread 👀
6:57 AM
for await ( let item of items )
            {
                const [[, prevValue],, [, data]] = item;
                const [devid, address, value, timestamp, table] = data.split('|');

                if( prevValue !== value ) {

                    sender
                        .table(config.questdb.tables[table])
                        .symbol("devid", devid)
                        .symbol("address", address)
                        .intColumn("value", valueFunction.set[table](value))
                        .booleanColumn("isFloat", table === 'float')
                        .timestampColumn("created_at", timestamp * 1e3);

                    await sender.flush();

                    counterCreated++;
                }
            }
6:57 AM
Here is me code
6:58 AM
But on each step of while i've error in console
6:59 AM
Error: Table name has already been set
7:00 AM
That's right because in liblary in method table is setup flag hasTable on true and because of this app throw exception
7:02 AM
But in nodejs-questdb-client in examples you load to buffor more than once row. I mean this:
// add rows to the buffer of the sender
    sender.table("prices").symbol("instrument", "EURUSD")
        .floatColumn("bid", 1.0195).floatColumn("ask", 1.0221).atNow();
    sender.table("prices").symbol("instrument", "GBPUSD")
        .floatColumn("bid", 1.2076).floatColumn("ask", 1.2082).atNow();
Andrey Pechkurov

Andrey Pechkurov

09/12/2022, 7:07 AM
Hello
7:07 AM
You should be using
at()
instead of
timestampColumn()
7:07 AM
The client expects each row write to end with either
at()
or
atNow()
7:09 AM
Keep in mind that timestamp value provided to
at()
call should be in nanoseconds
b

Bartosz

09/12/2022, 7:18 AM
@Andrey Pechkurov thank you for your answer. I'm using unfortunly two timestamps because devices connected to my service sometimes collecting data up to 15 minutes and then send to server, so i can't using all features from QuestDB like input lag with value 15 minutes. As i know records waiting to store after input lag, are not visible in query result until save. I don't setup timestamp because in docs i found description about auto add server time as ts. Am i right?
Andrey Pechkurov

Andrey Pechkurov

09/12/2022, 7:29 AM
So, your table doesn't have a designated timestamp column, right?
7:30 AM
If so, try adding
atNow()
call after
.timestampColumn("created_at", timestamp * 1e3)
. The client needs to know when to start a new line (row) and without this call it won't do that
b

Bartosz

09/12/2022, 9:06 AM
Ok, thank you. I found bug with my timestamp created_at (i should multiply in this case per 1e6 not 1e3 like before). But i've another problem and this looks like something damage with table... I've created similar test table and everythings looks fine, but in my main table modules_history i've problem with my socket client which using official node liblary. I mean this fail:
Error: This socket has been ended by the other party
at Socket.writeAfterFIN [as write]
Andrey Pechkurov

Andrey Pechkurov

09/12/2022, 9:08 AM
Looks like your client is trying to write to a closed socket
b

Bartosz

09/12/2022, 9:08 AM
But when i change table name to new it's working
Andrey Pechkurov

Andrey Pechkurov

09/12/2022, 9:08 AM
What kind of damage you're talking of?
b

Bartosz

09/12/2022, 9:10 AM
I'm not sure, but i did restart main process of QuestDB with same result - still not writable in modules_history
9:12 AM
Ok, i see difference... old table have created_at as date type not timestamp... so maybe this is the problem
9:13 AM
But type DATE is unsupported by node.js library ?
Andrey Pechkurov

Andrey Pechkurov

09/12/2022, 9:14 AM
The connection might get closed due to an invalid ILP message. You should check server logs
9:15 AM
You should be able to write DATE values as long numbers
b

Bartosz

09/12/2022, 9:26 AM
It's alive 😄
10:51 AM
Crap... after couple of minutes script throw exception
Error: Table name has already been set
Andrey Pechkurov

Andrey Pechkurov

09/12/2022, 10:53 AM
This is really weird. Can you reproduce this issue?
10:53 AM
Could also check server logs for any errors?
b

Bartosz

09/12/2022, 11:04 AM
It was my fault. Some parameters from my devices i convert on fly from float to int by multiply 10 before store in database, but i forgot in this case to parse incoming value from redis into int value.
Andrey Pechkurov

Andrey Pechkurov

09/12/2022, 11:21 AM
OK, good to know. Let me know if you face any issues