Skip to content

Add support for socketio/socket.io-redis-adapter onmessage Handler #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kinseyost
Copy link

https://github.com/socketio/socket.io-redis-adapter/blob/main/lib/index.ts#L215 The current parser blows up when socket.io-redis-atapter tries to call parser.decode (it doesn't exist on this parser)

Here you go :)

@darrachequesne
Copy link
Member

Hi! This parser is not meant to be used with the adapter, you can simply use:

import { createAdapter } from '@socket.io/redis-adapter';

io.adapter(createAdapter(pubClient, subClient, {
  parser: {
    decode(msg) {
      return JSON.parse(msg);
    },
    encode(msg) {
      return JSON.stringify(msg);
    },
  },
}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants