AbdoPrDZ / fixed-laravel-echo-server

The fixed version of laravel-echo-server (upgrade socket.io version to latest)
MIT License
1 stars 1 forks source link

TypeError: _this.io.of(...).in(...).clients is not a function #2

Closed HDVinnie closed 2 months ago

HDVinnie commented 2 months ago

fixed-laravel-echo-server start


  ╔═══╗            ╔╗     ╔╗                        ╔╗      ╔═══╗    ╔╗           ╔═══╗
  ║╔══╝            ║║     ║║                        ║║      ║╔══╝    ║║           ║╔═╗║
  ║╚══╗╔╗╔╗╔╗╔══╗╔═╝║     ║║   ╔══╗ ╔═╗╔══╗ ╔╗╔╗╔══╗║║      ║╚══╗╔══╗║╚═╗╔══╗     ║╚══╗╔══╗╔═╗╔╗╔╗╔══╗╔═╗
  ║╔══╝╠╣╚╬╬╝║╔╗║║╔╗║╔═══╗║║ ╔╗╚ ╗║ ║╔╝╚ ╗║ ║╚╝║║╔╗║║║ ╔═══╗║╔══╝║╔═╝║╔╗║║╔╗║╔═══╗╚══╗║║╔╗║║╔╝║╚╝║║╔╗║║╔╝
 ╔╝╚╗  ║║╔╬╬╗║║═╣║╚╝║╚═══╝║╚═╝║║╚╝╚╗║║ ║╚╝╚╗╚╗╔╝║║═╣║╚╗╚═══╝║╚══╗║╚═╗║║║║║╚╝║╚═══╝║╚═╝║║║═╣║║ ╚╗╔╝║║═╣║║
 ╚══╝  ╚╝╚╝╚╝╚══╝╚══╝     ╚═══╝╚═══╝╚╝ ╚═══╝ ╚╝ ╚══╝╚═╝     ╚═══╝╚══╝╚╝╚╝╚══╝     ╚═══╝╚══╝╚╝  ╚╝ ╚══╝╚╝
----------------------------------------------------------------------------------------------------------
|                                   Powered By AbdoPrDZ "Just Code It";                                  |
----------------------------------------------------------------------------------------------------------

version 0.1.1

Starting server...

✔ Running at localhost on port 8443 ✔ Listening for http events... ✔ Listening for redis events...

Server ready!

[2024-04-23T12:33:07.071Z] - ⚠ Client r9bNP2X5DCc1JYYzAAAB connected
/usr/lib/node_modules/@abdopr/fixed-laravel-echo-server/dist/channels/presence-channel.js:35
                .clients(function (error, clients) {
                 ^

TypeError: _this.io.of(...).in(...).clients is not a function
    at /usr/lib/node_modules/@abdopr/fixed-laravel-echo-server/dist/channels/presence-channel.js:35:18
    at new Promise (<anonymous>)
    at PresenceChannel.removeInactive (/usr/lib/node_modules/@abdopr/fixed-laravel-echo-server/dist/channels/presence-channel.js:31:16)
    at /usr/lib/node_modules/@abdopr/fixed-laravel-echo-server/dist/channels/presence-channel.js:20:23
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.12.1

I have been using https://github.com/tlaverdure/laravel-echo-server. Which works ok but two issues.

1) stuck on old socket.io "socket.io": "^2.4.0", "socket.io-client": "^2.3.1",

2) Server crashes from https://github.com/tlaverdure/laravel-echo-server/pull/535

Using your package which I really hope I can get, my chatbox does not work. All I see in browser console is

WebSocket connection to 'wss://xxx.dev:8443/socket.io/?EIO=4&transport=websocket' failed: Could not connect to the server.

Then error above popped up in terminal.

My chat.js looks like so:

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */
import Echo from 'laravel-echo';
import Vue from 'vue';
import chatbox from '../components/chat/Chatbox.vue';

import client from 'socket.io-client';

window.io = client;

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: import.meta.env.VITE_ECHO_ADDRESS,
    forceTLS: true,
    withCredentials: true,
    transports: ['websocket'],
    enabledTransports: ['wss'],
});

new Vue({
    el: '#vue',
    components: { chatbox: chatbox },
});
HDVinnie commented 2 months ago

This is my package.json

{
  "private": true,
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  },
  "dependencies": {
    "@abdopr/fixed-laravel-echo-server": "^0.1.1",
    "ajv": "^8.10.0",
    "alpinejs": "^3.9.1",
    "axios": "^0.26.1",
    "cross-env": "^7.0.3",
    "dayjs": "^1.11.0",
    "laravel-echo": "^1.11.4",
    "laravel-mix-purgecss": "^6.0.0",
    "postcss": "^8.4.12",
    "resolve-url-loader": "^5.0.0",
    "sass": "^1.49.9",
    "sass-loader": "^12.6.0",
    "socket.io": "4.7.5",
    "socket.io-client": "4.7.5",
    "sweetalert2": "^11.4.6",
    "virtual-select-plugin": "^1.0.26",
    "vue": "^2.6.14",
    "vue-loader": "^15.9.8",
    "vue-template-compiler": "^2.6.14"
  },
  "devDependencies": {
    "@vitejs/plugin-vue2": "^2.3.1",
    "laravel-vite-plugin": "^1.0.1",
    "prettier-plugin-blade": "^2.0.0",
    "vite": "^5.0.12",
    "vite-plugin-static-copy": "^1.0.1"
  },
  "type": "module"
}
AbdoPrDZ commented 2 months ago

Hi there

I think I've resolved all the issues related to the presence channel. You can now access the updated version 0.1.2.

Apologies for any inconvenience caused by these problems. I hadn't thoroughly reviewed the changes for the socket.io package 😅😅.

You can download the latest version using the following command:

$ npm i @abdopr/fixed-laravel-echo-server@^0.1.2

Or, if you prefer yarn:

$ yarn add @abdopr/fixed-laravel-echo-server@^0.1.2

Let me know if you encounter any further issues or need assistance!

HDVinnie commented 2 months ago

Working perfect now. Thank you for taking this fork on.