0

First of all I am sorry for my newbie question, but I am kinda stuck here. Could anyone please tell me step by step how to use Redis in my Rails 6 application, if I have Windows OS? I have installed Redis, currently it is in my C:\Program Files, with these files inside it

I started the redis-server.exe, when it starts running it says:

[8020] 20 Nov 17:26:06 # Warning: no config file specified, using the default config. 
In order to specify a config file use 'redis-server /path/to/redis.conf'

[8020] 20 Nov 17:26:06 * Server started, Redis version 2.4.6

[8020] 20 Nov 17:26:06 # Open data file dump.rdb: No such file or directory

[8020] 20 Nov 17:26:06 * The server is now ready to accept connections on port 6
379

[8020] 20 Nov 17:26:07 - 0 clients connected (0 slaves), 672768 bytes in use

[8020] 20 Nov 17:26:12 - 0 clients connected (0 slaves), 672768 bytes in use

[8020] 20 Nov 17:26:17 - 0 clients connected (0 slaves), 672768 bytes in use

.......... (it just keep outputs this same text every 5 seconds)

Also in my Rails application, I configured some things. I changed config/cable.yml file to:

development:
adapter: redis
url: redis://localhost:6379/1

test:
adapter: test

production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
channel_prefix: actioncable_test_production

My concept was to create a channel, named 'room', and output a message in the console, to see its successfully connected. But my problem is that it doesn't output anything.

I set app/javascript/channels/room_channel.js to:

import consumer from "./consumer"

consumer.subscriptions.create("RoomChannel", {
connected() {
// Called when the subscription is ready for use on the server
console.log("Connected succesfully!")
},

disconnected() {
// Called when the subscription has been terminated by the server
},

received(data) {
// Called when there's incoming data on the websocket for this channel
}
});

and my app/channels/room_channel.rb file to:

class RoomChannel < ApplicationCable::Channel
def subscribed
stream_from "room_channel"
end

def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end

Also, on my command prompt shows this: (after the usual rendering messages and things like that):

Started GET "/cable" for 127.0.0.1 at 2021-11-20 18:24:05 +0100
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2021-11-20 18:24:06 +0100
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-a
live, Upgrade, HTTP_UPGRADE: websocket)

When I go to the browser console, it says Firefox cannot create connection with ws://localhost:3000/cable

Any idea what's the problem here? Thanks for the answers and best regards, Rererbit!

1 Answer 1

2

You are using a very old and deprecated version of Redis, an abandoned project by Microsoft called OpenTech Redis.

I suggest you checkout Memurai. Memurai is an up-to-date native Windows port of Redis that derives from that project (see this commit).

Memurai is also available with a free Developer Edition.

Disclaimer: I work in Memurai.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.