Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with JSONata config #67

Open
PJ-Schulz opened this issue Jul 9, 2024 · 3 comments
Open

Error with JSONata config #67

PJ-Schulz opened this issue Jul 9, 2024 · 3 comments

Comments

@PJ-Schulz
Copy link
Contributor

I run NodeRed in Kubernetes and want to pass some environment variables like host, username, password and so on as environment variables to the container.

But when I use at least a small variant only with the host address i get an error.

9 Jul 13:29:10 - [error] [redis-config:Redis] Missing options in the redis config - Are you upgrading from old version?
9 Jul 13:29:10 - [error] [redis-config:Redis] Missing options in the redis config - Are you upgrading from old version?
9 Jul 13:29:10 - [error] [redis-in:02924f467d4f2799] TypeError: Cannot read properties of undefined (reading 'on')

This is the configuration of my redis instance:

{
  "host": $env('redis_host')
}

When I press the inject node which is configured with JSONata: $env('redis_host') I get the correct parameter I have set. So the environment variable will be passed correctly to the container and NodeRed can read it.

What must I change in my configuration to make it work?

PS: I am using this commit: 3410396 because I use NodeRed 4

My flow:

grafik

[{"id":"ec1fd2a9a2f3cff8","type":"tab","label":"Basic Flow","disabled":false,"info":"","env":[]},{"id":"e3b3d83b76ec9607","type":"redis-instance","z":"ec1fd2a9a2f3cff8","server":"73589485eb3882eb","name":"","topic":"redis","location":"global","x":190,"y":80,"wires":[]},{"id":"02924f467d4f2799","type":"redis-in","z":"ec1fd2a9a2f3cff8","server":"73589485eb3882eb","command":"subscribe","name":"","topic":"my-channel","obj":false,"timeout":"0","x":210,"y":140,"wires":[["db46548d837e7355"]]},{"id":"db46548d837e7355","type":"debug","z":"ec1fd2a9a2f3cff8","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":460,"y":140,"wires":[]},{"id":"153e64a7f777a1ed","type":"inject","z":"ec1fd2a9a2f3cff8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"$env('redis_host')","payloadType":"jsonata","x":190,"y":200,"wires":[["705347879b008e5c"]]},{"id":"705347879b008e5c","type":"debug","z":"ec1fd2a9a2f3cff8","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":460,"y":200,"wires":[]},{"id":"73589485eb3882eb","type":"redis-config","name":"Redis","options":"{\t  \"host\": $env('redis_host')\t}","cluster":false,"optionsType":"jsonata"}]
@alepdb
Copy link

alepdb commented Oct 10, 2024

Hi @PJ-Schulz !
I solved this issue setting the Redis connection url as env variable (ex: redis://arbitrary_usrname:password@ipaddress:6379/0) and importing it in configuration as "env variable". It's the only work-around I find to set a variable host to Redis connection.
Hope that helps! ✌🏻

@PJ-Schulz
Copy link
Contributor Author

Unfortunately it did not work for me to use the URL as an environment variable.
When i load this string redis://redis-user-nodered:dsklsjfhgi89fq=)HÖoddwr@redis-server:6379/0 as the environment variable REDIS_CONNECTION_URL and use it as "env variable" at the Redis instance i get this error: ReplyError: NOAUTH Authentication required.

As workaround i pass building the Json config in Kubernetes and pass this as full config to the Redis Instance Node. Maybe this helps other Users.

      containers:
        - name: nodered
          image: nodered/node-red:4.0.2
          env:
            - name: REDIS_CONFIG
              value: |
                {
                  "host": "redis-server",
                  "port": 6379,
                  "db": 0,
                  "username": "$(redis_username)",
                  "password": "$(redis_password)"
                }
          envFrom:
            - secretRef:
                name: redis-user-nodered  # containes the keys: "redis_username", "redis_password"
[{"id":"fbe90bceb1d71487","type":"redis-instance","z":"45b2d61a2048e5b7","server":"73589485eb3882eb","name":"","topic":"Redis","location":"global","x":230,"y":180,"wires":[]},{"id":"73589485eb3882eb","type":"redis-config","name":"Redis","options":"REDIS_CONFIG","cluster":false,"optionsType":"env"}]

@chameleonbr
Copy link
Owner

Hey @PJ-Schulz , you could help the community and contribute to this project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants