Posts

Showing posts with the label redis

ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context

Image
Clash Royale CLAN TAG #URR8PPP ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / PING / QUIT allowed in this context I am using jdish.publish in my web app and jedis.subscribe in my desktop app. so both are separate app. jdish.publish jedis.subscribe I have this pubsub class public class RedisNewPostListener extends JedisPubSub { private final Jedis jedis; private final AppInstances appInstances; public RedisNewPostListener(AppInstances instances, Jedis jedis) { this.jedis = jedis; appInstances = instances; } @Override public void onMessage(String channel, String message) { String pos = message.split("##"); double lat = Double.parseDouble(pos[0]); double lon = Double.parseDouble(pos[1]); List<GeoRadiusResponse> members = jedis.georadius("UsersByLocation", lon, lat, GEO_SEARCH_RANGE, GeoUnit.KM); i am calling it like RedisNewPostListener postListener = new RedisNewPostListener(instances, jedis); j...

How to get local heroku app to connect to remote REDIS?

Image
Clash Royale CLAN TAG #URR8PPP How to get local heroku app to connect to remote REDIS? I am new to Heroku/Redis. I have created a basic node.js and express APP to which I have added a REDIS addon. heroku addons:create heroku-redis:hobby-dev -a MyApp I have an index.js from which the server runs on port 5000 index.js const express = require('express') const path = require('path') const PORT = process.env.PORT || 5000 const client = require('redis').createClient(process.env.REDIS_URL); express() .use(express.static(path.join(__dirname, 'public'))) .set('views', path.join(__dirname, 'views')) .set('view engine', 'ejs') .get('/', (req, res) => res.render('pages/index')) .listen(PORT, () => console.log(`Listening on ${ PORT }`)) My repo is connected to my personal github from Heroku where the app runs fine, but whenever I try to run it locally it seems it tries to connect to REDIS locally so I h...

node.js schedule reminder system

Image
Clash Royale CLAN TAG #URR8PPP node.js schedule reminder system I am trying to build a system based on nodejs where users will be receiving push notifications from server. Use case: from (Date), to (Date), remindTime (time), message (text) I have problem with design it effectively. Based on my days of surfing I have reached the following solution: /remind _id remindTime I am not sure that it is right approach to solve this problem. I've read about redis-queue based solutions using ZSET, but I don't feel where is the power of using such approach. My system is not time critical - if user will receive notification +/- 5min nothing bad will happened. I must stick to self-hosted solutions without any third-party services. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to...