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 6379[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: redisurl: redis://localhost:6379/1test:adapter: testproduction:adapter: redisurl: <%= 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 serverconsole.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::Channeldef subscribedstream_from "room_channel"enddef unsubscribed# Any cleanup needed when channel is unsubscribedendend
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 +0100Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2021-11-20 18:24:06 +0100Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, 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!