Redis on heroku without RedisToGo add-on - heroku

Can we use redis on heroku for background jobs with python without using RedisToGo add-on. Any pointer please.
I've this error while following this https://devcenter.heroku.com/articles/python-rq post without using RedisToGo add-on
app[worker.1]: Error 111 connecting to localhost:6379. Connection refused.

Heroku does not include a redis server by default. You will have to use a Heroku add-on or connect to another instance you control.

Related

Does Heroku provide any VPN client like AWS Client VPN?

I want to host a database in Heroku server and also a django application. The problem is: To transfer data to my Heroku database i would need be connected to a VPN. Does Heroku provides a way to connect to a VPN in order to access another database, like AWS client VPN?
My infra would be like this:
Airflow running DAGs to pull data from a AWS database that requires VPN connection to source from it. I would transfer the data from this AWS database to my heroku database.
Is it possible?
Thank you
Another thing that i'm wondering is if it is possible to connect Heroku to AWS client VPN, in case Heroku does not have something similar or a way to do this step.
Yes Heroku does provides a VPN labelled as Heroku Private Spaces and Shield Spaces.
Here is the link
https://devcenter.heroku.com/articles/private-space-vpn-connection

Why is #nestjs/bull not able to connect to Heroku Redis?

This works for local redis-server
BullModule.forRoot({
redis: {
host: "localhost",
port: 6379,
db: 0,
password: ""
}
})
But if I use the DataStore Credentials on Heroku Redis, the bull board does not load and Heroku Logs gives an H12 error.
How can I get the BullModule to properly connect to Heroku Data for Redis?
Thanks!
You must specify the location of where redis is accessible. localhost:6379 is the default for running redis locally, but to deploy an application that uses Redis to Heroku, you will need to add the Connecting to Heroku Data for Redis add-on. Then, you'll need to pass the location of your Redis service via process.env.REDIS_URL to the BullModule.forRoot() constructor.
Be aware that encountering TLS issues in connecting to Redis like this are common. When I tried connecting using the format from PedroPovedaQ's answer, I ran into one.
There's a discusson on that here.
I suggest trying
BullModule.forRoot({
redis: "<redisurl given by heroku in env variable>"
})
This fixed the issue for me.

Heroku CLI gives "No Redis instances found" yet I have a redis cloud addon running and usable

I'm learning redis and have it working from a java app. I'm trying to use the heroku redis:cli -a myAppName command to connect with it directly but it says "No Redis instances found".
When I do heroku apps it lists myAppName so I know it's valid.
heroku redis:info -a myAppName doesn't return anything.
The heroku docs don't seem to be accurate as they all leave out the -a flag which the cli tells me is required. Outside of that I don't know what I've missed.
You are looking at documentation for Heroku Redis, a hosted Redis service that Heroku itself provides. If you wish to use Heroku Redis, you can provision it for your app using like so:
heroku addons:create heroku-redis:hobby-dev -a your-app-name
Pricing for Heroku Redis can be found here. The Hobby Dev plan used in the previous command is free.
There are also other Redis providers that can be provisioned this way, including Redis Enterprise Cloud. Or you can use existing hosted Redis server. But with these options you won't be able to interact with the service using heroku redis commands. Use whatever tooling those providers offer.

Is it possible to whitelist Heroku apps?

I have a Heroku application that binds with a telco sms gateway via SMPP
The telco guys need to whitelist IPs for my app to connect.
I am aware of the new addon proximo, but it's just insanely priced. So that option is out.
Is there a subnet or a list of IPs that I can get whitelisted and is there a guarantee that all requests from my app will originate from tose IPs?
I found this https://api.heroku.com/vendor/logplex/allowlist.
Is that only for syslog or all apps make a request from one of those IPs?
Thanks
There is now a Heroku add-on that does this called Proximo: https://addons.heroku.com/proximo
The Heroku docs specifically mention how dynos don't have static IP addresses. Even when using custom domains it looks like they want you to point to a CNAME record rather than an IP address. So if you need a static IP it looks like Proximo is your best bet.
Would it be possible to use an API token to authenticate your app with the sms gateway, similar to the way the blitz.ip plugin works with heroku? Then you might not need to use a static IP whitelist.
This question looks to be doing something similar to you, and this answer suggests using a hosted VPN service. Would that work?
Heroku now has Private Spaces which is what you are looking for:
https://www.heroku.com/private-spaces
Another Heroku addon option is Quotaguard , in beta, free for now.
Answering my own question. Even though an external VPN or the proximo addon are a solution in case you want to whitelist a Heroku app, I have decided to go for the simpler option and host the SMPP binding service of my app on ec2 using an Elastic IP
You can host a proxy yourself using Dockhero Heroku add-on - https://dockhero.io/ - which has a static IP (AWS elastic IP).
Install the add-on and the CLI plugin:
$ heroku addons:create dockhero
$ heroku plugins:install dockhero
Wait until the provisioning is done and get DOCKHERO_HOST environment variable
$ heroku dh:wait
$ heroku config:get DOCKHERO_HOST
--> e.g. dockhero-spherical-42047.dockhero.io
Create dockhero-compose.yml file with the following contents:
version: "2"
services:
proxy:
image: tecnativa/tcp-proxy
environment:
LISTEN: ":80"
TALK: "www.wikipedia.org:80"
ports:
- "80:80"
Here www.wikipedia.org:80 is the server which you build a proxy for.
Find more about the syntax in https://docs.docker.com/compose/compose-file/compose-file-v2/
Run this stack in the cloud using Dockhero CLI:
$ heroku dh:compose up -d
Any requests to the host from DOCKHERO_HOST Heroku config var will now be proxied according to your dockhero-compose.yml
$ curl http://dockhero-spherical-42047.dockhero.io/
--> <response from www.wikipedia.org>
IMPORTANT: as of writing this, dockhero.io is in Beta and available for free. When switching to production, the assigned IP may be changed after a prior notification.
Fixie is another alternative add-on not mentioned here. Free plan with 500 requests per month. Requires some adjustments in code and heroku app to be in us region (or you can migrate it: Migrating an Application to Another Region). Worked for me.

How to use your own mysql database server with heroku?

I want to use mysql database which is hosted on my own server.
I've changed DATABASE_URL and SHARED_DATABASE_URL config vars to point to my server, but it's still trying to connect to heroku's amazonaws servers. How do I fix that?
According to the Heroku documentation, changing DATABASE_URL is the correct way to go.
If you would like to have your rails application connect to a non-Heroku provided database, you can take advantage of this same mechanism. Simply set your DATABASE_URL config var to point to any cloud-accessible database, and Heroku will automatically create your database.yml file to point to your chosen server. The Amazon RDS Add-on does this for you automatically, though you can also use this same method to connect to non-RDS databases as well.
Here's an example that should work:
heroku config:add DATABASE_URL=mysql://user:password#host/db
You may need to redeploy by making a change and running git push heroku master
By the way, the host is XXXX.amazonaws.com, where XXX is a long host hame that probably changes. If you can add a wildcard, that's the easiest %.amazonaws.com
I had this exact same problem with my Dreamhost MySQL database. Turns out the solution was to tell Dreamhost is was Ok to accept connections from this foreign host. Otherwise, Dreamhost blocks all requests to MySQL that don't originate from their systems.
It seems that if Heroku is falling back to Amazon AWS despite your DATABASE_URL, it's because it's being denied access to your MySQL database.

Resources