How to setup a basic websocket connection

I have just started to explore RoR and not able to setup a websocket test connection which shows in browser console logs as “connected”.

I have setup the things with ActionCable like routes and creating a channel. How do I test the websocket connection? I just see nothing in developer tools which means client is not able to connect to websocket.

Here are my setup files:

route file:

mount ActionCable.server => '/cable'

cat config/cable.yml

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

production.rb file

config.action_cable.url = "wss://192.168.122.162/cable"
config.action_cable.allowed_request_origins = [ "http://192.168.122.162" ]

app/channels/messages_channel.rb

class MessagesChannel < ApplicationCable::Channel
  def subscribed
     stream_from 'MessagesChannel'
  end

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

app/javascript/channels/consumer.js

import { createConsumer } from "@rails/actioncable"
//export default createConsumer()
export default createConsumer("wss://192.168.122.162/cable")

app/javascript/channels/messages_channel.js

import consumer from "channels/consumer"

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

  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
  }
});

I am using passenger with nginx with below contents:

    passenger_root /home/test/.rvm/gems/ruby-3.1.4/gems/passenger-6.0.18;
    passenger_ruby /home/test/.rvm/gems/ruby-3.1.4/wrappers/ruby;
server {
        listen       80;
        server_name  192.168.122.162;

location /cable {
        passenger_app_group_name my_app_action_cable;
        passenger_force_max_concurrent_requests_per_process 0;
    }
root /var/www/my_app/public;
         passenger_enabled on;
         rails_env production;
         passenger_ruby /home/test/.rvm/gems/ruby-3.1.4/wrappers/ruby;