Nest: Configuring SocketIO before launch

Created on 20 Aug 2018  路  6Comments  路  Source: nestjs/nest

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

How can I configure SocketIO before it gets initialized. For example If I want to specify redis adapter by default for all gateways with: https://github.com/socketio/socket.io-redis instead of specifying the redis-adapter in each @Gateway decorator?

Couldn't find anything in the docs

Thank you.

websockets question 馃檶

All 6 comments

@avatsaev

I don't have a answer in regards to the docs, but if there's a way to pass it to the gateway, maybe you can define the config in a separate .ts file and import to the gateway file.

This at least reduces some of the redundant code usage.

Yeah this is weird, redis adapter is for Socket.IO at scale, and considering NestJS tends to be a fw for applications at large scales, it's weird that we can't specify a default redis adapter for all Gateways at bootstrap time.

I've found this: https://docs.nestjs.com/websockets/adapter thinking I could just directly pass redisAdapter instead of a custom adapter, but redisAdapter is not compliant to the WebSocketAdapter interface.

I'll update the docs very soon, hopefully today

See https://docs.nestjs.com/websockets/adapter "Extend socket.io` chapter

This is exactly what i needed, thank you @kamilmysliwiec

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xmlking picture xmlking  路  28Comments

roeehershko picture roeehershko  路  27Comments

ArsalaBangash picture ArsalaBangash  路  27Comments

chaostheory picture chaostheory  路  34Comments

raydirty picture raydirty  路  37Comments