socket.io-redis-adapter
socket.io-redis-adapter copied to clipboard
TypeError: socket.client.writeToEngine is not a function
Getting the following error trying to get redis working with socketio and express.
TypeError: socket.client.writeToEngine is not a function at <PROJECT_DIRECTORY>/server/node_modules/@socket.io/redis-adapter/node_modules/socket.io-adapter/dist/index.js:119:31
Few others here have also flagged this, but I don't see any workaround. socket.io-redis-adapter is the latest version, 7.0.0.
My socketio instance is being created like this:
--
// Create the SocketIO Server const express = require('express'); const http = require('http'); const sio = require('socket.io'); const redisAdapter = require('@socket.io/redis-adapter'); const { createClient } = require("redis");
. . . const app = express(); const server = http.createServer(app); const io = new sio.Server(server); const pubClient = createClient({ port : [redacted], host : [redacted], password : [redacted] }); const subClient = pubClient.duplicate() io.adapter(redisAdapter(pubClient, subClient));
It looks like a version mismatch. Could you please check the version of socket.io
?
socketio version is 4.0.1
Upgrading socketio to 4.3.1 seems to have fixed the issue
@aintHuman how about downgrading the redis adapter to 6.1.1?
Anyways, I think version shouldn't be the problem, as the compatibility table says that redis adapter "6.1.x and above" should match socket.io server of "4.x".
Hello. I encountered this problem. I got rid of the problem when I updated my packages as below.
"@socket.io/redis-adapter": "^7.2.0", "redis": "3.1.2", "socket.io": "4.5.1",
For future readers: this error was due to an incompatibility between the socket.io
, socket.io-adapter
and @socket.io/redis-adapter
packages. Updating to the latest revision should fix the issue.
Please reopen if needed.