socket.io-redis | Using redis pubsub to push messages via socket | Socket library

 by   KristianOellegaard JavaScript Version: Current License: No License

kandi X-RAY | socket.io-redis Summary

kandi X-RAY | socket.io-redis Summary

socket.io-redis is a JavaScript library typically used in Networking, Socket, Kafka applications. socket.io-redis has no bugs, it has no vulnerabilities and it has low support. You can download it from GitHub.

You think socket.io is very cool, but do not want to write your server-side webapplication in .. javascript. Using this very simple snippet, you can push your data into redis from any programming language and socket.io will then push it to the client.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              socket.io-redis has a low active ecosystem.
              It has 17 star(s) with 3 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              socket.io-redis has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of socket.io-redis is current.

            kandi-Quality Quality

              socket.io-redis has 0 bugs and 0 code smells.

            kandi-Security Security

              socket.io-redis has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              socket.io-redis code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              socket.io-redis does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              socket.io-redis releases are not available. You will need to build from source code and install.
              Installation instructions, 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 will need node.js to run the socket.io server, you can grab it at http://nodejs.org/#download - this should install the node package manager as well "npm".

            Support

            Bugfixes can be sent as pullrequests or be posted as an issue. If you know how to send a message to redis pubsub in any language feel free to make me a pull request with it included.
            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/KristianOellegaard/socket.io-redis.git

          • CLI

            gh repo clone KristianOellegaard/socket.io-redis

          • sshUrl

            git@github.com:KristianOellegaard/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 KristianOellegaard

            django-health-check

            by KristianOellegaardPython

            django-hvad

            by KristianOellegaardPython

            python-eureka

            by KristianOellegaardPython

            django-saml-service-provider

            by KristianOellegaardPython

            zsh-plugins

            by KristianOellegaardShell