Skip to content
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

UnhandledPromiseRejection when trying to add a RedisAdapter to socketIO #513

Open
AndrieuGirard opened this issue Aug 28, 2023 · 0 comments

Comments

@AndrieuGirard
Copy link

AndrieuGirard commented Aug 28, 2023

Hi everyone,
I'm facing Unhandled Rejection when adding RedisAdapter to my socketIO server. Using this syntax : io.adapter(createAdapter(pubClient, subClient));

After many breakpoints through my own project and @socket.io >redis-adapter > dist > index.js file. It appears that the real problem is that my client has no permissions to perform subscribe, psubscribe and publish commands. The solution is then to add these commands in the white list of the redis server for the given user.

Yes but ... I can't let unhandled rejection occur in my project..

Off course I attached "error" listeners on both sub and pub clients but it still rejects out of them. I tried all the possible listeners on as many object that inherit from EventEmitter as I could find hoping that it would solve my problem but still nothing.

I don't think showing you block of code will be of any help for you since I would not know what to show.

Below, the trace of the process.on('unhandledRejection', ...) eventListener that just tells me what I already know

Unhandled Rejection at: Promise Promise { <rejected> [ErrorReply: NOPERM this user has no permissions to run the 'psubscribe' command], [Symbol(async_id_symbol)]: 2709, [Symbol(trigger_async_id_symbol)]: 2609, [Symbol(destroyed)]: { destroyed: false } } reason: [ErrorReply: NOPERM this user has no permissions to run the 'psubscribe' command] at process.<anonymous> (C:\Users\33778\Documents\Stage Ubikap\ubikap-back\src\main\js\server.js:154:17) at process.emit (events.js:400:28) at process.emit (domain.js:475:12) at processPromiseRejections (internal/process/promises.js:245:33) at processTicksAndRejections (internal/process/task_queues.js:96:32) Trace: Unhandled Rejection at: Promise Promise { <rejected> [ErrorReply: NOPERM this user has no permissions to run the 'subscribe' command], [Symbol(async_id_symbol)]: 2711, [Symbol(trigger_async_id_symbol)]: 2609, [Symbol(destroyed)]: { destroyed: false } } reason: [ErrorReply: NOPERM this user has no permissions to run the 'subscribe' command] at process.<anonymous> (C:\Users\33778\Documents\Stage Ubikap\ubikap-back\src\main\js\server.js:154:17) at process.emit (events.js:400:28) at process.emit (domain.js:475:12) at processPromiseRejections (internal/process/promises.js:245:33) at processTicksAndRejections (internal/process/task_queues.js:96:32)

I also checked inside the @socket.io >redis-adapter > dist > index.js and breakpointed the constructor where some of the "forbidden" commands are called. In this file, the client well and truely has "error" eventListener in its _events property.

The problem may be that in this file, it seems that there is no error handling of any kind.
Could the "error" eventListener of the client only be triggered when redis commands are called within the project files and therefore not in the redisAdapter initialization ?

Does anyone ever faced the same problem and found a solution ?

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

No branches or pull requests

1 participant