socket.io-redis | enable broadcasting of events to multiple separate socket | Socket library

 by   socketio TypeScript Version: 6.1.0 License: MIT

kandi X-RAY | socket.io-redis Summary

kandi X-RAY | socket.io-redis Summary

socket.io-redis is a TypeScript library typically used in Networking, Socket, Nodejs applications. socket.io-redis has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

Adapter to enable broadcasting of events to multiple separate socket.io server nodes.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              socket.io-redis has a medium active ecosystem.
              It has 2426 star(s) with 443 fork(s). There are 150 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 16 open issues and 238 have been closed. On average issues are closed in 173 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of socket.io-redis is 6.1.0

            kandi-Quality Quality

              socket.io-redis has no bugs reported.

            kandi-Security Security

              socket.io-redis has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              socket.io-redis is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              socket.io-redis releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of socket.io-redis
            Get all kandi verified functions for this library.

            socket.io-redis Key Features

            No Key Features are available at this moment for socket.io-redis.

            socket.io-redis Examples and Code Snippets

            No Code Snippets are available at this moment for socket.io-redis.

            Community Discussions

            QUESTION

            Get socket object
            Asked 2021-May-15 at 00:26

            I'm using socket.io together with redis and I need to get the socket object since there's data I need to access that's added during the middleware.

            When I do this:

            ...

            ANSWER

            Answered 2021-May-14 at 20:14

            In socket.io v4, you can do:

            Source https://stackoverflow.com/questions/67539684

            QUESTION

            how to access socket session in all clusters
            Asked 2021-Apr-10 at 20:59

            I am working on setting up socket.io in cluster mode using PM2.

            I am using socket.io-redis package and it works fine in cluster mode.

            But the problem arises when I want to access all connected sockets. Because processes don't know about socket connections in other processes in cluster mode.

            I thought socket.io-redis keeps track of all the connected sockets and all its session info but it didn't. Is there any way or solution to access all the socket connection existing in all processes in socket.io/Nodejs?

            ...

            ANSWER

            Answered 2021-Apr-10 at 20:59

            Socket.io-redis does keep track in a sense..

            From their docs

            "The Redis adapter extends the broadcast function of the in-memory adapter: the packet is also published to a Redis channel (see below for the format of the channel name).

            Each Socket.IO server receives this packet and broadcasts it to its own list of connected sockets."

            So basically, redis is used as the broker to tell each socket server to emit based on X channel etc. Allowing you to have a socket.io server in cluster mode work, but as you have mentioned it can fall short when you need to keep track of things outside of just an emit.

            So where does this leave us.. Well you can use custom hooks via socket.io-redis but personally I found it to be really difficult to understand and use and had limited success personally. I think with the new version of socket.io and socket.io redis there were some tweaks to make this simpler however I have not tried them.

            Instead, what we do is use redis hset and jget to store the socket and an ID of a users, then when we want to get all users online we can query redis to get the list of online users or users in a specific room etc.

            What you will want to do is add the redis package and connect in additon to the regular pub / sub.

            Then, when a user joins a room or your server for that matter you will do an hset. On the first join ours looks something like this

            Source https://stackoverflow.com/questions/67034796

            QUESTION

            TypeError: this.adapter.add is not a function
            Asked 2021-Mar-11 at 06:04

            I'm using socket.io "^1.7.1", and "socket.io-redis": "^6.0.1" when I am doing the following

            ...

            ANSWER

            Answered 2021-Mar-11 at 06:04

            So, I was doing some research and it turned out that my socket.io-redis version was not compatible with socket.io. I have updated my socket.io version to 2.4.1 and not this issue is resovled.

            Source https://stackoverflow.com/questions/66571327

            QUESTION

            Flask-SocketIO: Passing events between nodes (Redis-Adapter)
            Asked 2020-Sep-26 at 18:26

            When using SocketIO in an application that runs behind a node-balancer, the official documentation states the way to pass events between those nodes (using SocketIO-Redis):

            ...

            ANSWER

            Answered 2020-Sep-26 at 18:26

            How would one implement a Redis-Adapter when using the SocketIO-JS-standalone version?

            I don't know why you use "standalone" here. I think you mean the JavaScript Socket.IO client, which does not have anything to do with Redis, regardless of what Socket.IO server you use.

            The Redis support is implemented by the server. For the Node Socket.IO server you use the Redis-Adapter project. For the Python Socket.IO server the support for Redis comes built-in, you just need to add the message_queue argument when you create your server object, as shown in the docs.

            Source https://stackoverflow.com/questions/64064884

            QUESTION

            socket.io messages sent from client aren't received in server
            Asked 2020-Sep-07 at 12:17

            I am trying to play around with socket.io and figure out if it suits us. I have ran into a problem while trying stuff out.

            so in my server i have the following code:

            ...

            ANSWER

            Answered 2020-Sep-07 at 12:17

            QUESTION

            I can't connect Elasticache to Elastic Beanstalk (In VPC)
            Asked 2020-Jun-10 at 01:29

            I have a VPC with 2 public subnets in different availability zones (public subnet-2a and public-subnet-2b). I have two private subnets (private-2a-EB-Instance, private-2b-EB-Instance), and two other private subnets for Elasticache (private-2a-EB-Instance, private-2b-EB-Instance), these two subnets for elasticache are part of a subnet group that I use when creating my Elasticache clusters.

            I have create a security group for my ElastiCache(redis) and I have changed its inbound rules so it can accept connection from the security group of my ElasticBeanstalk environment. Didn't solve the problem.

            I have followed the instructions on AWS' website, and I can't get it to work. I wonder what I am doing wrong. I am using socket-io-redis and I am wondering if that may be part of the problem.

            I have used the .config file offered here , but I get an error when deploying the app. It says there was an error creating it.

            I created the cluster from the console and tried to connect it to my EB app using the "Primary Endpoint", but I get the error:

            ...

            ANSWER

            Answered 2020-Jun-10 at 01:29

            I think the problem is that you have included https:// in what is supposed to be the hostname. Redis does not connect over HTTP, it uses its own protocol. The error message getaddrinfo ENOTFOUND https://myelasticache.xxxxxxxxx.cache.amazonaws.com indicates that it is trying to resolve https://myelasticache.xxxxxxxxx.cache.amazonaws.com when you want it to use myelasticache.xxxxxxxxx.cache.amazonaws.com.

            So try removing https:// and see if it works or if you get another error.

            Source https://stackoverflow.com/questions/62294144

            QUESTION

            How to build a scalable realtime chat messaging with Websocket?
            Asked 2020-Apr-27 at 12:44

            I'm trying to build a realtime (private) chat between users of a video game with 25K+ concurrent connections. We currently run 32 nodes where users can connect through a load balancer. The problem I'm trying to solve is how to route messages to each user?

            Currently, we are using socket.io & socket.io-redis, where each websocket joins a room with its user ID, and we emit each message they should receive to that room. The problem with this design is that we are reaching the limits of Redis Pubsub, and Socket.io which doesn't scale well (socket.io emit messages to all nodes which check if the user is connected, this is not viable).

            Our current stack is composed of Postgres, Redis & RabbitMQ. I have been thinking about this problem a lot and have come up with 3 different solutions :

            • Route all messages with RabbitMQ. When a user connects, we create an exchange with type fanout with the user ID and a queue per websocket connection (we have to handle multiple connections per user). When we want to emit to that user, we simply publish to that exchange. The problem with that approach is that we have to create a lot of queues, and I heard that this may not be very efficient.
            • Create a queue for each node in RabbitMQ. When a user connects, we save the node & socket ID in a Redis Set, so that when we have to send a message to that specific user, we first get the list of nodes, emit to each node queue, which then handle routing to specific client in the app. The problems with that approach is that in the case of a node failure, we may store that a user is connected when this is not the case. To fix that, we would need to expire the users's Redis entry but this is not a perfect fix. Also, if we later want to implement group chat, it would mean we have to send duplicates messages in Rabbit, this is not ideal.
            • Go all in with Firebase Cloud Messaging. We have a mobile app, and we plan to use it for push notifications when the user isn't connected, but would it be a good fit even if the user is connected?

            What do you think is the best fit for our use case? Do you have any other idea?

            ...

            ANSWER

            Answered 2020-Apr-27 at 12:44

            I found a better solution : create a binding for each user but using only one queue on each node, then we route each messages to each user.

            Source https://stackoverflow.com/questions/61405784

            QUESTION

            block routes when database unavailable (graceful "shutdown")
            Asked 2020-Apr-23 at 17:07

            I'm building a web server in nodejs which relies on redis, postgresql and mongodb. I store all the credentials in the google cloud secret manager, so I have to use asynchronous functions to get them. My code so far:

            ...

            ANSWER

            Answered 2020-Apr-23 at 17:07

            you should not do it at application level. ideally it should be handle by your infra.

            at app level, implement a health check route, and do your logic there. eg: if mysql or redis is down, return 500 error. infra will see that error and stop routing traffic to that instance / server / container.

            Source https://stackoverflow.com/questions/61391621

            QUESTION

            Socket.io-redis gives error when added as adapter to Socket.io instance
            Asked 2020-Mar-06 at 19:24

            Im experimenting abit with Socket.io and Socket.Io-redis. I have my Redis server up and running. The error i get when starting the Socket.Io server is: ReplyError: ERR unknown command 'pubsub' I dont know why i get this error at all.

            The Redis version i'm using is 2.4.5

            ...

            ANSWER

            Answered 2020-Mar-06 at 19:24

            I fixed it by installing latest version of Redis! :)

            Source https://stackoverflow.com/questions/60554478

            QUESTION

            npm run scripts does not working
            Asked 2020-Mar-05 at 22:59

            I have just initialized a new project with Node.js and trying making the scripts in package.json file to be working.

            For example I have the next package.json file:

            ...

            ANSWER

            Answered 2020-Mar-05 at 22:59
            npm config set ignore-scripts false
            

            Source https://stackoverflow.com/questions/51314162

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install socket.io-redis

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/socketio/socket.io-redis.git

          • CLI

            gh repo clone socketio/socket.io-redis

          • sshUrl

            git@github.com:socketio/socket.io-redis.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Socket Libraries

            monolog

            by Seldaek

            libuv

            by libuv

            log.io

            by NarrativeScience

            Flask-SocketIO

            by miguelgrinberg

            Try Top Libraries by socketio

            socket.io

            by socketioTypeScript

            socket.io-client

            by socketioTypeScript

            socket.io-client-java

            by socketioJava

            socket.io-client-swift

            by socketioSwift

            engine.io

            by socketioJavaScript