Search code examples
rredisdata-streamnosql

How to connect to Redis using R (rredis and specific socket)


I am totally new to Redis and relatively new to R. I need to do an assignment, where I first need to connect to a socket (it streams key-values for stocks).

I installed Redis in my mac using homebrew, and then the package rredis in R. Everytime I try to connect to local host I get the following error:

redisConnect()
Warning message:
In .openConnection(host = host, port = port, nodelay = nodelay,  :
  Unable to set nodelay.

If I set nodelay = F I get connected

Now, I am trying to connect to a specific socket (ip: 88.99.38.191, port:1337)

I get this

redisConnect(host = "88.99.38.191", port = 1337)
Error:  Error in doTryCatch(return(expr), name, parentenv, handler): 

Unknown message type

Warning message:
In .openConnection(host = host, port = port, nodelay = nodelay,  :
  Unable to set nodelay.

and if I try to set nodelay = F :

 > redisConnect(host = "88.99.38.191", port = 1337, nodelay = F)
Error:  Error in doTryCatch(return(expr), name, parentenv, handler): Unknown message type

Warning messages:
1: closing unused connection 12 (->localhost:6379) 
2: closing unused connection 11 (->localhost:6379) 
3: closing unused connection 10 (->localhost:6379) 
4: closing unused connection 9 (->localhost:6379) 

Does anyone have anyidea what I do wrong? All guides/ tutorials that I have seen in the web have no problem in default settings of nodelay = T

ps: Please forgive my ignorance, or I there is anysimilar post, I didn't manage to find any.


Solution

  • For those interested the connection to socket is established like this

    con <- socketConnection(host="88.99.38.191", port = 1337, blocking=T, server=FALSE, open="r+")

    it has nothing to do with redis. Redis is listening to a local ip, while redisConnect is used in order to connect to remote redis server.

    Additional info can be found here.