Connect to Heroku redis from a nestjs app - heroku

I am hosting my nestjs application on Heroku and trying to use "Heroku redis" add-on with it.
In the app.module.ts I am importing RedisModule as follows:
#Module({
imports: [
RedisModule.register({ host: process.env.REDIS_URL })
]
})
After configuring Heroku-redis add-on, it added REDIS_URL under config vars in Heroku, however, when I deploy and run the application, I get the following error message:
2020-06-11T09:00:48.690255+00:00 app[web.1]: [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND redis://h:abc#ec2-52-51-206-63.eu-west-1.compute.amazonaws.com:16719
(I've replaced the real url value with a sample one to illustrate the problem)
I can't seem to find

RedisModule.register({ url: process.env.REDIS_URL })

Related

Serverless Deploy crashing for ruby app using serverless-ruby-package on mac

I am using serverless for building aws app on a mac. When I do not use the "serverless-ruby-package" and deploy, I get
"errorMessage": "cannot load such file -- curb",
as the gems are not properly compiled.
The moment I add
plugins:
- serverless-ruby-package
and execute
sls deploy
or
sls package
I get
Type Error ----------------------------------------------
TypeError: Cannot read property 'push' of undefined
at PackageRubyBundlePlugin.beforePackage (/Users/xxxxxx/node_modules/serverless-ruby-package/index.js:85:45)
at PluginManager.invoke (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:576:20)
at async PluginManager.run (/usr/local/lib/node_modules/serverless/lib/classes/PluginManager.js:634:7)
at async Serverless.run (/usr/local/lib/node_modules/serverless/lib/Serverless.js:327:5)
at async /usr/local/lib/node_modules/serverless/scripts/serverless.js:704:9
This looks to be a bug with the serverless-ruby-package plugin, as it's been reported by other users
You may consider adding a comment here.

Bug CleverBeagle Pup 2.0 Meteor GraphQL deployment on Heroku

1) In the first time, when I deployed the origin code to heroku server with git clone https://github.com/cleverbeagle/pup
The launching application didn't work.
I managed to correct this with to copy the content of 'settings-development.json' file and paste in Heroku => myProject => Setttings => Reveal Config Vars => Key : METEOR_SETTINGS and Value : I pasted here the content.
thanks to :
- https://github.com/cleverbeagle/pup/issues/9
- https://github.com/cleverbeagle/pup/issues/197
So, now, the app is showing on server.
2) On Chrome console, I have this error :
50d72c91808ef7fba57f920b67d152d2d57698eb.js?meteor_js_resource=true:9 WebSocket connection to 'ws://localhost:4001/graphql' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
so I changed this in METEOR_SETTINGS
"graphQL": {
"httpUri": "http://localhost:3000/graphql",
"wsUri": "ws://localhost:4001/graphql"
},
to
"graphQL": {
"httpUri": "https://myproject.herokuapp.com:3000/graphql",
"wsUri": "wss://myproject.herokuapp.com:4001/graphql"
},
Note without https and wss, the app is not showing
3) Now on Chrome Console, I have :
this warning :
50d72c91808ef7fba57f920b67d152d2d57698eb.js?meteor_js_resource=true:9 WebSocket connection to 'wss://myproject.herokuapp.com:4001/graphql' failed: WebSocket is closed before the connection is established.
and after several warning above, I have this error :
50d72c91808ef7fba57f920b67d152d2d57698eb.js?meteor_js_resource=true:9 WebSocket connection to 'wss://myproject.herokuapp.com:4001/graphql' failed: WebSocket opening handshake timed out
By using the origin source code from Pup, I can signup on server but I cannot create a new document.
Any help, please ?
Thank you
EDIT 15 JAN 2019
**4) I remove Port like this : **
"httpUri": "https://myproject.herokuapp.com/graphql",
"wsUri": "wss://myproject.herokuapp.com/graphql"
Now, I can create New document on https://myproject.herokuapp.com/documents
but I still have this warning :
fe6fa1ac83e19aa2513ac3f97293600e8dc99e8e.js?meteor_js_resource=true:9
WebSocket connection to 'wss://myproject.herokuapp.com/graphql'
failed: WebSocket is closed before the connection is established.
and this error :
WebSocket connection to 'wss://myproject.herokuapp.com/graphql'
failed: Error during WebSocket handshake: Unexpected response code:
503
any idea ?
Thanks

prisma graphql token fails to verify when deployed in heroku

I have deployed a Graphql Yoga Server in Heroku using a Prisma service as Database and I have also deploy the frontend which is a nextjs app on Heroku as well. When I try to perform a upsert operation using the prisma db connection, it fails saying [GraphQL error]: Message: Your token is invalid. It might have expired or you might be using a token from a different project., Location: undefined, Path: undefined. I have gone through similar issues on Prisma's Github issues, couldn't find anything helpful.
prisma_db connection:
const db = new Prisma({
typeDefs: 'src/generated/prisma.graphql',
endpoint: process.env.PRISMA_ENDPOINT,
secret: process.env.PRISMA_SECRET,
debug: true,
});
prisma.yml:
endpoint: ${env:PRISMA_ENDPOINT}
datamodel: datamodel.prisma
secret: ${env:PRISMA_SECRET}
# disableAuth: true
hooks:
post-deploy:
- graphql get-schema -p prisma
I have set the PRISMA_ENDPOINT and PRISMA_SECRET in the Heroku config vars. To make sure both the .yml file and the DB connection have the same secret token. I have also set the secret token to be something relatively simple, consider secret123, so that there are no special characters as well.
Entire Error:
2018-12-21T07:08:45.107583+00:00 app[web.1]: [GraphQL error]: Message: Your token is invalid. It might have expired or you might be using a token from a different project., Location: undefined, Path: undefined
2018-12-21T07:08:45.108037+00:00 app[web.1]: [Network error]: Error: Your token is invalid. It might have expired or you might be using a token from a different project.
2018-12-21T07:08:45.115464+00:00 app[web.1]: { Error: Your token is invalid. It might have expired or you might be using a token from a different project.
2018-12-21T07:08:45.115467+00:00 app[web.1]: at BatchedGraphQLClient.<anonymous> (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:69:35)
2018-12-21T07:08:45.115469+00:00 app[web.1]: at step (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:40:23)
2018-12-21T07:08:45.115471+00:00 app[web.1]: at Object.next (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:21:53)
2018-12-21T07:08:45.115472+00:00 app[web.1]: at fulfilled (/app/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:12:58)
2018-12-21T07:08:45.115474+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:68:7)
2018-12-21T07:08:45.115476+00:00 app[web.1]: message:
2018-12-21T07:08:45.115478+00:00 app[web.1]: 'Your token is invalid. It might have expired or you might be using a token from a different project.',
2018-12-21T07:08:45.115480+00:00 app[web.1]: locations: [],
2018-12-21T07:08:45.115482+00:00 app[web.1]: path: [ 'upsertUser' ] }
For info: when I try to perform the same upsert operation from the Prisma playground, it works fine. Can someone please tell me where I am going wrong? Thanks in advance.

KeystoneJS with letsencrypt - certificate files required

I am following this tutorial Let’s Encrypt KeystoneJS! in an attempt to get letsencrypt working on my KeystoneJS project.
However, when I start the server I am getting the error:
SSL Not Started: Invalid SSL Configuration (certificate files required)
I've generated the standalone certificate with certbot to the directory /home/example/letenscrypt resulting in:
- accounts
- csr
- keys
- letsencrypt.log
- renewal
- renewal-hooks
I've also tried defining the configdir in my keystone init:
keystone.init({
...
letsencrypt: (process.env.NODE_ENV === 'production') && {
email: 'admin#myapp.com',
domains: ['www.myapp.com', 'myapp.com'],
register: true,
tos: true,
configDir: '/home/example/letsencrypt'
},
...
})
I've also tried configDir: '/home/example/letsencrypt/keys' but I always get the same error, I'm wondering what I'm missing?
Ok, so the issue was the NODE_ENV wasn't correctly set to production. Setting it properly in my .env solved this issue (but raised another unfortunately with an invalid certificate being generated)
https://github.com/keystonejs/keystone/wiki/Deployment-Checklist

Cannot run in production mode

I have a donejs application and its running ok in development mode donejs develop, but when I run it in production mode:
donejs build
donejs deploy (to firebase)
NODE_ENV=production donejs start
it will not start and show an error (see CODE A)
This file: file:my-app/dist/bundles/my-app/index.js:704 corresponds to JQuery 3.x and its not a dependency of the project itself but a dependency of can-connect-feathers (https://github.com/canjs/can-connect-feathers). In fact in index.js there is also included JQuery 2.x what makes me think there might be some sort of incompatibility among them.
I already tried changing the project's dependency to JQuery 3.x but didn't help. Actually it will make even donejs develop fail (see CODE B).
I also tried the following:
cd my-app/node_modules/steal
npm install
but didn't help, another error appears and finally tried cd my-app/node_modules/can && npm install but that end up in multiple errors.
I'm using:
donejs#0.9.2
node#4.6.2
npm#2.15.11
can-connect-feathers#1.2.1
CODE A
NODE_ENV=production donejs start
my-app#0.0.0 start my-app
done-serve --proxy http://localhost:3030 --port 8080
done-serve starting on http://localhost:8080
Potentially unhandled rejection [5] TypeError: Error loading "package.json!npm" at file:my-app/package.json
Error loading "bundles/my-app/index" at file:my-app/dist/bundles/my-app/index.js
Error evaluating file:my-app/dist/bundles/my-app/index.js
Cannot read property 'createElement' of undefined
at i (file:my-app/dist/bundles/my-app/index.js:704:20)
at file:my-app/dist/bundles/my-app/index.js:1039:2881
at file:my-app/dist/bundles/my-app/index.js:1039:3580
at file:my-app/dist/bundles/my-app/index.js:268:21
at file:my-app/dist/bundles/my-app/index.js:268:27
at Object.exports.runInThisContext (vm.js:54:17)
at doEval (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:2059:10)
at __eval (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:1976:7)
at Loader.exec [as __exec] (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:339:5)
at Loader.loader.instantiate (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:1517:16)
CODE B
donejs develop
my-app#0.0.0 develop my-app
done-serve --develop --proxy http://localhost:3030 --port 8080
done-serve starting on http://localhost:8080
Potentially unhandled rejection [8] Error: Error loading "my-app#0.0.0#index.stache!done-autorender#0.8.0#autorender" at <unknown>
Error loading "can#2.3.27#util/jquery/jquery" at file:my-app/node_modules/can/util/jquery/jquery.js
Error loading "can#2.3.27#util/jquery/jquery" from "done-autorender#0.8.0#autorender" at file:my-app/node_modules/done-autorender/src/autorender.js
Did not find ./node_modules/can/node_modules/jquery/package.json
at FetchTask.utils.extend.next (file:my-app/node_modules/steal/ext/npm-crawl.js:532:11)
at file:my-app/node_modules/steal/ext/npm-crawl.js:556:33
at tryCatchReject (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1183:30)
at runContinuation1 (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1142:4)
at Fulfilled.when (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:930:4)
at Pending.run (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:821:13)
at Scheduler._drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:97:19)
at Scheduler.drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:62:9)
at nextTickCallbackWith0Args (node.js:436:9)
at process._tickCallback (node.js:365:13)
Potentially unhandled rejection [16] Error: Error loading "can#2.3.27#util/jquery/jquery" at file:my-app/node_modules/can/util/jquery/jquery.js
Error loading "can#2.3.27#util/jquery/jquery" from "my-app#0.0.0#index.stache!done-autorender#0.8.0#autorender" at file:my-app/src/index.stache
Did not find ./node_modules/can/node_modules/jquery/package.json
at FetchTask.utils.extend.next (file:my-app/node_modules/steal/ext/npm-crawl.js:532:11)
at file:my-app/node_modules/steal/ext/npm-crawl.js:556:33
at tryCatchReject (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1183:30)
at runContinuation1 (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1142:4)
at Fulfilled.when (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:930:4)
at Pending.run (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:821:13)
at Scheduler._drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:97:19)
at Scheduler.drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:62:9)
at nextTickCallbackWith0Args (node.js:436:9)
at process._tickCallback (node.js:365:13)
If the double jQuery installation is the issue, it should be resolved by version 2.0.0, which is exactly the same as the 1.0 version, but requires that you pass in a jQuery package as the jquery option. So, in addition to whatever else you had in your can-connect-feathers config, you'll need to provide the jquery option:
import $ from 'jquery'
import Feathers from 'can-connect-feathers';
new Feathers({
jquery: $
});

Resources