Hi,
I've been trying to communicate with Postgres database that runs locally on a Raspberry pi.
So far I think that I have tried every node available through the Palette, such as
node-red-contrib-postgres-variable
node-red-contrib-re-postgres
node-red-contrib-postgres-multi
Postgrestor
..and others
All of them fail with a TypeError and cause Node-RED to restart, the moment a query is sent to the database. Here is the log:
Welcome to Node-RED
===================
13 Nov 22:41:55 - [info] Node-RED version: v1.0.2
13 Nov 22:41:55 - [info] Node.js version: v10.17.0
13 Nov 22:41:55 - [info] Linux 4.19.75-v7l+ arm LE
13 Nov 22:41:56 - [info] Loading palette nodes
13 Nov 22:42:03 - [info] Dashboard version 2.17.1 started at /ui
13 Nov 22:42:03 - [info] Settings file : /home/pi/.node-red/settings.js
13 Nov 22:42:03 - [info] Context store : 'default' [module=memory]
13 Nov 22:42:03 - [info] User directory : /home/pi/.node-red
13 Nov 22:42:03 - [info] Server now running at http://127.0.0.1:1880/
13 Nov 22:42:03 - [info] Active project : ggln25wb
13 Nov 22:42:03 - [info] Flows file : /home/pi/.node-red/projects/ggln25wb/flow.json
13 Nov 22:42:04 - [info] Starting flows
13 Nov 22:42:05 - [info] Started flows
13 Nov 22:42:18 - [red] Uncaught Exception:
13 Nov 22:42:18 - TypeError: Second argument must be a string or a buffer.
at Connection.parseCString (/home/pi/.node-red/node_modules/pg/lib/connection.js:649:20)
at Connection.parseE (/home/pi/.node-red/node_modules/pg/lib/connection.js:548:30)
at Connection.parseMessage (/home/pi/.node-red/node_modules/pg/lib/connection.js:378:19)
at Socket. (/home/pi/.node-red/node_modules/pg/lib/connection.js:119:22)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:287:12)
at readableAddChunk (_stream_readable.js:268:11)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
nodered.service: Main process exited, code=exited, status=1/FAILURE
nodered.service: Failed with result 'exit-code'.
nodered.service: Service RestartSec=100ms expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 1.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
13 Nov 22:42:20 - [info]
Welcome to Node-RED
===================
13 Nov 22:42:20 - [info] Node-RED version: v1.0.2
13 Nov 22:42:20 - [info] Node.js version: v10.17.0
13 Nov 22:42:20 - [info] Linux 4.19.75-v7l+ arm LE
13 Nov 22:42:22 - [info] Loading palette nodes
13 Nov 22:42:28 - [info] Dashboard version 2.17.1 started at /ui
13 Nov 22:42:29 - [info] Settings file : /home/pi/.node-red/settings.js
13 Nov 22:42:29 - [info] Context store : 'default' [module=memory]
13 Nov 22:42:29 - [info] User directory : /home/pi/.node-red
13 Nov 22:42:29 - [info] Server now running at http://127.0.0.1:1880/
13 Nov 22:42:29 - [info] Active project : ggln25wb
13 Nov 22:42:29 - [info] Flows file : /home/pi/.node-red/projects/ggln25wb/flow.json
13 Nov 22:42:29 - [info] Starting flows
13 Nov 22:42:30 - [info] Started flows
My flow is a simple one, with just one select statement that should return one row from the database:
Query:
msg.payload = 'SELECT * FROM table1 limit 1;';
return msg;
Connection settings:
Postgres node:
Am I missing something?
Using the same connection parameters, I can connect and select records without problems, using Pyhton. Also pgAdmin connects normally.