CLOUD FUNCTION REDIS NOT CONNECTING TO GCP SERVERLESS VCP CONNECTOR(MEMORYSTORE-REDIS))

I followed this video : https://www.youtube.com/watch?v=hRbN5aTtgHc&ab_channel=thecloudfunction

where first
I created a serverless vcp connector in serverless vcp access with an IP range 10.0.0.0/28
then
I created memorystore with the same IP range
after that, i added roles in the google cloud function service agent
roles I added was
compute network user
serverless vcp access user
then I copied code from this repo: https://github.com/thecloudfunction/cf_redis101/blob/master/functions/src/index.ts

after deploying the function
I go to GCP dashboard → cloud functions ->redis
edited the function → connection and selected the VCP connector which I created at the start

now my redis in cloud function is connecting to localhost instead of the IP:port I provided

Your error message seems to say that the function is attempting to reach REDIS at 127.0.0.1. That can’t be right. Can we look really carefully at your cloud function code to see what it is using as the host to call REDIS? If you can, post the exact source code you are using for testing. Have you hard coded the REDIS host that is being sought?

yes i tried hard coding it, still same issue

I am by no means a REDIS specialist … but i looked at the code you are using:

const client = redis_client.createClient(REDIS_PORT, REDIS_HOST)

and compared that against the REDIS docs found here. I wasn’t able to find a match for the parameters you supplied. What I seem to have found is:

createClient({
   url: "redis://<HOST>:<PORT>"
});

What I’d like to suggest is that you look carefully at the createClient API call that you are coding and compare that against the docs and other examples. It may be you have gotten your hands on some old or broken sample that is no longer correct with respect to how to invoke Redis.

yes I tried that

i tried removing client.connect()