Heroku Tails suggesting postgres database column doesn't exist, but it does and works in localhost - postgresql

I have an app deployed on heroku. My production and dev environments both use PostgreSQL and I use knex for my database querying. I am getting an issue where no resources load onto a page and heroku log --tail says this:
2022-08-23T21:34:19.565970+00:00 app[web.1]: There is an error here: select *, "authors"."name" as "author_name", "authors"."id" as "author_id" from "books" inner join "authors" on "books"."author_id" = "authors"."id" where "books"."id" = $1 limit $2 - column books.author_id does not exist
However, the call works fine on localhost - I have checked my database schema on pgadmin and it appears that the column does exist.
Here is the call to the database:
function getBookById(id) {
console.log(id)
return db('books')
.join('authors', 'books.author_id', 'authors.id')
.where('books.id', id)
.select('*', 'authors.name as author_name', 'authors.id as author_id')
.first()
}
I have done a bit more diving in and looks like it is breaking on a number of database hits and returning 503s.
Here is some more error messages I am getting when I run heroku log --tail
2022-08-24T02:25:36.434109+00:00 app[web.1]: at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:287:98)
2022-08-24T02:25:36.434109+00:00 app[web.1]: at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
2022-08-24T02:25:36.434110+00:00 app[web.1]: at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
2022-08-24T02:25:36.434110+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
2022-08-24T02:25:36.434111+00:00 app[web.1]: at TLSSocket.emit (node:events:513:28)
2022-08-24T02:25:36.434112+00:00 app[web.1]: at addChunk (node:internal/streams/readable:315:12)
2022-08-24T02:25:36.434112+00:00 app[web.1]: at readableAddChunk (node:internal/streams/readable:289:9)
2022-08-24T02:25:36.434112+00:00 app[web.1]: at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
2022-08-24T02:25:36.434113+00:00 app[web.1]: at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23) {
2022-08-24T02:25:36.434113+00:00 app[web.1]: length: 127,
2022-08-24T02:25:36.434114+00:00 app[web.1]: severity: 'ERROR',
2022-08-24T02:25:36.434114+00:00 app[web.1]: code: '42703',
2022-08-24T02:25:36.434114+00:00 app[web.1]: detail: undefined,
2022-08-24T02:25:36.434115+00:00 app[web.1]: hint: undefined,
2022-08-24T02:25:36.434115+00:00 app[web.1]: position: '22',
2022-08-24T02:25:36.434115+00:00 app[web.1]: internalPosition: undefined,
2022-08-24T02:25:36.434115+00:00 app[web.1]: internalQuery: undefined,
2022-08-24T02:25:36.434116+00:00 app[web.1]: where: undefined,
2022-08-24T02:25:36.434116+00:00 app[web.1]: schema: undefined,
2022-08-24T02:25:36.434116+00:00 app[web.1]: table: undefined,
2022-08-24T02:25:36.434116+00:00 app[web.1]: column: undefined,
2022-08-24T02:25:36.434117+00:00 app[web.1]: dataType: undefined,
2022-08-24T02:25:36.434117+00:00 app[web.1]: constraint: undefined,
2022-08-24T02:25:36.434117+00:00 app[web.1]: file: 'parse_target.c',
2022-08-24T02:25:36.434118+00:00 app[web.1]: line: '1061',
2022-08-24T02:25:36.434118+00:00 app[web.1]: routine: 'checkInsertTargets'
2022-08-24T02:25:36.434118+00:00 app[web.1]: }
2022-08-24T02:25:36.434240+00:00 app[web.1]: There is an error here: insert into "books" ("author_id", "blurb", "cover_image", "genre", "pub_year", "title") values ($1, $2, $3, $4, $5, $6) returning "id" - column "author_id" of relation "books" does not exist
I'm not sure if this is something weird with heroku's postgres - or something I'm doing wrong (more likely). It is unclear to me how to further trouble shoot this issue.
Thanks for an help

Related

Vapor Server of Heroku Crashes: Possible Postgres Library Issue?

I'm putting this new information first: the problem that brought me to this point is below.
This is what I get once my app deploys to Heroku: seems to compile fine, though there is the issue described in the original section of the post. Now, following the suggestion in the comments, the authentication error seems to be gon, but an encryption problem has arisen...
2022-04-20T07:05:05.960239+00:00 heroku[web.1]: State changed from crashed to starting
2022-04-20T07:05:08.667673+00:00 heroku[web.1]: Starting process with command `Run serve --env production --hostname 0.0.0.0 --port 57625`
2022-04-20T07:05:10.017468+00:00 app[web.1]: Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PostgresNIO.PSQLError(base: PostgresNIO.PSQLError.Base.server(PostgresNIO.PostgresBackendMessage.ErrorResponse(fields: [Line: "545", Severity: "FATAL", Localized Severity: "FATAL", Code: "28000", File: "auth.c", Routine: "ClientAuthentication", Message: "no pg_hba.conf entry for host \"52.87.192.140\", user \"gcnpqdmtllqlsa\", database \"d71dlsuretksud\", no encryption"])))
2022-04-20T07:05:10.017484+00:00 app[web.1]: Current stack trace:
2022-04-20T07:05:10.017998+00:00 app[web.1]: 0 libswiftCore.so 0x00007fb4a3e93210 swift_reportError + 50
2022-04-20T07:05:10.018318+00:00 app[web.1]: 1 libswiftCore.so 0x00007fb4a3f07fc0 _swift_stdlib_reportFatalErrorInFile + 112
2022-04-20T07:05:10.018535+00:00 app[web.1]: 2 libswiftCore.so 0x00007fb4a3bf0c40 _assertionFailure(_:_:file:line:flags:) + 1329
2022-04-20T07:05:10.018759+00:00 app[web.1]: 3 libswiftCore.so 0x00007fb4a3c5fea0 swift_errorInMain + 1075
2022-04-20T07:05:10.018772+00:00 app[web.1]: 4 0x000055b6cab352e8 <unavailable> + 10863336
2022-04-20T07:05:10.018824+00:00 app[web.1]: 5 libc.so.6 0x00007fb4a2ca8fc0 __libc_start_main + 243
2022-04-20T07:05:10.018826+00:00 app[web.1]: 6 0x000055b6ca23aeae <unavailable> + 1449646
2022-04-20T07:05:10.018870+00:00 app[web.1]: Received signal 4. Backtrace:
2022-04-20T07:05:10.231212+00:00 app[web.1]: 0x55b6ca473552, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /tmp/build_64fa1ab2/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
2022-04-20T07:05:10.231216+00:00 app[web.1]: 0x7fb4a3a6d3bf
2022-04-20T07:05:10.231216+00:00 app[web.1]: 0x7fb4a3bf1307
2022-04-20T07:05:10.231216+00:00 app[web.1]: 0x7fb4a3c602d2
2022-04-20T07:05:10.231242+00:00 app[web.1]: 0x55b6cab352e7, main at /tmp/build_64fa1ab2/<compiler-generated>:0
2022-04-20T07:05:10.231250+00:00 app[web.1]: 0x7fb4a2ca90b2
2022-04-20T07:05:10.231258+00:00 app[web.1]: 0x55b6ca23aead
2022-04-20T07:05:10.231260+00:00 app[web.1]: 0xffffffffffffffff
2022-04-20T07:05:10.354561+00:00 heroku[web.1]: Process exited with status 132
2022-04-20T07:05:10.414827+00:00 heroku[web.1]: State changed from starting to crashed
2022-04-20T07:05:10.424640+00:00 heroku[web.1]: State changed from crashed to starting
2022-04-20T07:05:13.246896+00:00 heroku[web.1]: Starting process with command `Run serve --env production --hostname 0.0.0.0 --port 54624`
2022-04-20T07:05:14.462106+00:00 app[web.1]: Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PostgresNIO.PSQLError(base: PostgresNIO.PSQLError.Base.server(PostgresNIO.PostgresBackendMessage.ErrorResponse(fields: [Severity: "FATAL", Code: "28000", File: "auth.c", Localized Severity: "FATAL", Line: "545", Routine: "ClientAuthentication", Message: "no pg_hba.conf entry for host \"3.237.11.112\", user \"gcnpqdmtllqlsa\", database \"d71dlsuretksud\", no encryption"])))
2022-04-20T07:05:14.462121+00:00 app[web.1]: Current stack trace:
2022-04-20T07:05:14.462395+00:00 app[web.1]: 0 libswiftCore.so 0x00007fe7be7d4210 swift_reportError + 50
2022-04-20T07:05:14.462580+00:00 app[web.1]: 1 libswiftCore.so 0x00007fe7be848fc0 _swift_stdlib_reportFatalErrorInFile + 112
2022-04-20T07:05:14.462693+00:00 app[web.1]: 2 libswiftCore.so 0x00007fe7be531c40 _assertionFailure(_:_:file:line:flags:) + 1329
2022-04-20T07:05:14.462816+00:00 app[web.1]: 3 libswiftCore.so 0x00007fe7be5a0ea0 swift_errorInMain + 1075
2022-04-20T07:05:14.462824+00:00 app[web.1]: 4 0x000055ab278fb2e8 <unavailable> + 10863336
2022-04-20T07:05:14.462847+00:00 app[web.1]: 5 libc.so.6 0x00007fe7bd5e9fc0 __libc_start_main + 243
2022-04-20T07:05:14.462849+00:00 app[web.1]: 6 0x000055ab27000eae <unavailable> + 1449646
2022-04-20T07:05:14.462881+00:00 app[web.1]: Received signal 4. Backtrace:
2022-04-20T07:05:14.631921+00:00 app[web.1]: 0x55ab27239552, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /tmp/build_64fa1ab2/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
2022-04-20T07:05:14.631960+00:00 app[web.1]: 0x7fe7be3ae3bf
2022-04-20T07:05:14.631979+00:00 app[web.1]: 0x7fe7be532307
2022-04-20T07:05:14.631996+00:00 app[web.1]: 0x7fe7be5a12d2
2022-04-20T07:05:14.632053+00:00 app[web.1]: 0x55ab278fb2e7, main at /tmp/build_64fa1ab2/<compiler-generated>:0
2022-04-20T07:05:14.632070+00:00 app[web.1]: 0x7fe7bd5ea0b2
2022-04-20T07:05:14.632086+00:00 app[web.1]: 0x55ab27000ead
2022-04-20T07:05:14.632101+00:00 app[web.1]: 0xffffffffffffffff
2022-04-20T07:05:14.757480+00:00 heroku[web.1]: Process exited with status 132
2022-04-20T07:05:14.897128+00:00 heroku[web.1]: State changed from starting to crashed
2022-04-20T07:05:27.957078+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-journey-01336.herokuapp.com request_id=4e9b80e0-0b48-4075-be82-08ed26aa14b8 fwd="49.156.46.15" dyno= connect= service= status=503 bytes= protocol=http
ORIGINAL POST =====================
I have a production server that works fine. I'm implementing a Staging server, and with a few bumps to get it to deploy, it now does that.
However, after launching, it crashes when I try to load it at https: with no certificate. I then restarted, and loaded it as http: but still got this feedback in Heroku logs:
022-04-20T06:15:47.340383+00:00 heroku[web.1]: State changed from crashed to starting
2022-04-20T06:15:50.014593+00:00 heroku[web.1]: Starting process with command `Run serve --env production --hostname 0.0.0.0 --port 57964`
2022-04-20T06:15:51.051520+00:00 app[web.1]: Swift/ErrorType.swift:200: Fatal error: Error raised at top level: PostgresNIO.PSQLError(base: PostgresNIO.PSQLError.Base.connectionError(underlying: NIOSSL.NIOSSLError.handshakeFailed(NIOSSL.BoringSSLError.sslError([Error: 268435581 error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED]))))
2022-04-20T06:15:51.051534+00:00 app[web.1]: Current stack trace:
2022-04-20T06:15:51.051817+00:00 app[web.1]: 0 libswiftCore.so 0x00007f5736109210 swift_reportError + 50
2022-04-20T06:15:51.051993+00:00 app[web.1]: 1 libswiftCore.so 0x00007f573617dfc0 _swift_stdlib_reportFatalErrorInFile + 112
2022-04-20T06:15:51.052106+00:00 app[web.1]: 2 libswiftCore.so 0x00007f5735e66c40 _assertionFailure(_:_:file:line:flags:) + 1329
2022-04-20T06:15:51.052221+00:00 app[web.1]: 3 libswiftCore.so 0x00007f5735ed5ea0 swift_errorInMain + 1075
2022-04-20T06:15:51.052229+00:00 app[web.1]: 4 0x000055c7c48aa528 <unavailable> + 10863912
2022-04-20T06:15:51.052252+00:00 app[web.1]: 5 libc.so.6 0x00007f5734f1efc0 __libc_start_main + 243
2022-04-20T06:15:51.052254+00:00 app[web.1]: 6 0x000055c7c3fafeae <unavailable> + 1449646
2022-04-20T06:15:51.052284+00:00 app[web.1]: Received signal 4. Backtrace:
2022-04-20T06:15:51.189690+00:00 app[web.1]: 0x55c7c41e8792, Backtrace.(printBacktrace in _B82A8C0ED7C904841114FDF244F9E58E)(signal: Swift.Int32) -> () at /tmp/build_113febab/.build/checkouts/swift-backtrace/Sources/Backtrace/Backtrace.swift:66
2022-04-20T06:15:51.189696+00:00 app[web.1]: 0x7f5735ce33bf
2022-04-20T06:15:51.189696+00:00 app[web.1]: 0x7f5735e67307
2022-04-20T06:15:51.189697+00:00 app[web.1]: 0x7f5735ed62d2
2022-04-20T06:15:51.189697+00:00 app[web.1]: 0x55c7c48aa527, main at /tmp/build_113febab/<compiler-generated>:0
2022-04-20T06:15:51.189698+00:00 app[web.1]: 0x7f5734f1f0b2
2022-04-20T06:15:51.189698+00:00 app[web.1]: 0x55c7c3fafead
2022-04-20T06:15:51.189698+00:00 app[web.1]: 0xffffffffffffffff
2022-04-20T06:15:51.318955+00:00 heroku[web.1]: Process exited with status 132
2022-04-20T06:15:51.366529+00:00 heroku[web.1]: State changed from starting to crashed
2022-04-20T06:15:54.612759+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=intense-journey-01336.herokuapp.com request_id=de9eeae6-ed50-46a7-8008-9e4c4937d71f fwd="49.156.46.15" dyno= connect= service= status=503 bytes= protocol=http
The PostgresNIO.PSQLError may relate to a problem that showed up while uploading it, where the compiler complained that a method being used in one of the Postgres libraries:
[898/900] Compiling PostgresKit ConnectionPool+Postgres.swift
/tmp/build_4aa2d012/.build/checkouts/postgres-kit/Sources/PostgresKit/PostgresConnectionSource.swift:53:39: warning: 'connect(to:tlsConfiguration:serverHostname:logger:on:)' is deprecated: Use the new connect method that allows you to connect and authenticate in a single step
return PostgresConnection.connect(
^
/tmp/build_4aa2d012/.build/checkouts/postgres-kit/Sources/PostgresKit/PostgresConnectionSource.swift:53:39: note: use 'connect(on:configuration:id:logger:)' instead
return PostgresConnection.connect(
^~~~~~~
connect
/tmp/build_4aa2d012/.build/checkouts/postgres-kit/Sources/PostgresKit/PostgresConnectionSource.swift:60:29: warning: 'authenticate(username:database:password:logger:)' is deprecated: Use the new connect method that allows you to connect and authenticate in a single step
return conn.authenticate(
^
/tmp/build_4aa2d012/.build/checkouts/postgres-kit/Sources/PostgresKit/PostgresConnectionSource.swift:60:29: note: use 'connect(on:configuration:id:logger:)' instead
return conn.authenticate(
^~~~~~~~~~~~
connect
[899/901] Compiling FluentPostgresDriver Exports.swift
Can anyone provide any context here, or a solution? My intention was to run the Staging server without SSL for now, but I wonder if that would help anyway, if the above is the problem, since it comes up during compile... no other errors are reported during the push to Heroku, btw.
It is about correct database connection configuration
In our case on heroku we set database url
postgres://xxx:yyy#zzz.compute-1.amazonaws.com:5432/asdfasgsgbwev
And tlsConfig.certificateVerification = .none

Heroku app fails to connect to mongodb atlas server (after migration from mlab)

I recently migrated from mlab to mongodb atlas due to its deprecation. I managed to successfully get a connection to the db and tested it with the mongoDB compass but when I add the environment variable to heroku it gives me the following error message:
MongoNetworkError: failed to connect to server [cluster-grwbxfbx-shard-00-02.e6jtl.mongodb.net:27017] on first connect [MongoNetworkError: connection 4 to cluster-grwbxfbx-shard-00-02.e6jtl.mongodb.net:27017 closed
2020-11-11T23:53:44.726144+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connection.js:372:9)
2020-11-11T23:53:44.726144+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2020-11-11T23:53:44.726145+00:00 app[web.1]: at TLSSocket.emit (events.js:314:20)
2020-11-11T23:53:44.726145+00:00 app[web.1]: at net.js:676:12
2020-11-11T23:53:44.726146+00:00 app[web.1]: at TCP.done (_tls_wrap.js:568:7)]
2020-11-11T23:53:44.726147+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb/lib/core/topologies/server.js:438:11)
2020-11-11T23:53:44.726147+00:00 app[web.1]: at Pool.emit (events.js:314:20)
2020-11-11T23:53:44.726148+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/pool.js:562:14
2020-11-11T23:53:44.726149+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/pool.js:1009:9
2020-11-11T23:53:44.726149+00:00 app[web.1]: at callback (/app/node_modules/mongodb/lib/core/connection/connect.js:97:5)
2020-11-11T23:53:44.726150+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/connect.js:124:7
2020-11-11T23:53:44.726150+00:00 app[web.1]: at _callback (/app/node_modules/mongodb/lib/core/connection/connect.js:349:5)
2020-11-11T23:53:44.726151+00:00 app[web.1]: at Connection.errorHandler (/app/node_modules/mongodb/lib/core/connection/connect.js:365:5)
2020-11-11T23:53:44.726151+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2020-11-11T23:53:44.726151+00:00 app[web.1]: at Connection.emit (events.js:314:20)
2020-11-11T23:53:44.726152+00:00 app[web.1]: at TLSSocket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connection.js:370:12)
2020-11-11T23:53:44.726152+00:00 app[web.1]: at Object.onceWrapper (events.js:421:26)
2020-11-11T23:53:44.726153+00:00 app[web.1]: at TLSSocket.emit (events.js:314:20)
2020-11-11T23:53:44.726153+00:00 app[web.1]: at net.js:676:12
2020-11-11T23:53:44.726153+00:00 app[web.1]: at TCP.done (_tls_wrap.js:568:7)
2020-11-11T23:53:44.812696+00:00 heroku[web.1]: Process exited with status 0
2020-11-11T23:53:44.850554+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-11T23:53:44.854049+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-11T23:53:47.149749+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-11T23:53:49.907225+00:00 app[web.1]:
It seems as if heroku is adding a port to the end of the MONGODB_URI. Does anyone know whats going on?
my config var in heroku is:
MONGODB_URI = mongodb+srv://username:password#cluster-grwbxfbx.e6jtl.mongodb.net/test?retryWrites=true&w=majority
with username and password being replaced by my admin username and password.
Also here is my code for connecting to the db
import mongoose from 'mongoose'
import options from '../config'
export const connect = (url = options.dbUrl, opts = {}) => {
return mongoose.connect(url, { ...opts, useNewUrlParser: true })
}
export const config = {
secrets: {
jwt: 'learneverything'
},
dbUrl: process.env.MONGODB_URI || 'mongodb://localhost:27017/api-design'
}
Let me know if you need me to post anything else

What is this Mongoose CursorNotFound Error?

I have mongoose throwing this error from time to time, it's not stopping the node application from running but I can't find any information about whats causing the error and I would like to fix it.
The link to the repo is here https://github.com/bkawk/divergence2
I have found I can stop the error by adding a limit to the records here
https://github.com/bkawk/divergence2/blob/master/src/db.js#L94
{ MongoError: cursor id 31871209567 not found
at /Users/bkawk/Documents/divergence2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:598:61
at authenticateStragglers (/Users/bkawk/Documents/divergence2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:516:16)
at Connection.messageHandler (/Users/bkawk/Documents/divergence2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:552:5)
at emitMessageHandler (/Users/bkawk/Documents/divergence2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:309:10)
at Socket.<anonymous> (/Users/bkawk/Documents/divergence2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:488:15)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:607:20)
name: 'MongoError',
message: 'cursor id 31871209567 not found',
ok: 0,
errmsg: 'cursor id 31871209567 not found',
code: 43,
codeName: 'CursorNotFound' }

Receive Parse.push.send using cloud function succeed but device not receiving push notification

I tried to use Parse.push.send with cloud function I define to send out a push notification to a device. I follow the guide on CodePath Guide and I receive a success call back in my iOS App. However, none of the remote notification was delivered. I also have the _p_installationKey in my _User collection, and I can verify that the _Installation collection also have an entry matching the address stored in the _User collection. For each cloud function I call, one _PushStatus entry will be inserted, but numSent is 0. Below are the collections stored in my MLab and my environment.
_PushStatus
{
"_id": "3mxSHXoZa0",
"pushTime": "2017-05-19T17:38:46.346Z",
"query": "{\"deviceType\":\"ios\"}",
"payload": "{\"alert\":\"Message: Testing\"}",
"source": "rest",
"status": "running",
"numSent": 0,
"pushHash": "424b520d52c5e20b4eb95be535cb2d54",
"_wperm": [],
"_rperm": [],
"_acl": {},
"_created_at": {
"$date": "2017-05-19T17:38:46.346Z"
},
"_updated_at": {
"$date": "2017-05-19T17:38:46.408Z"
},
"count": 1
}
_Installation
{
"_id": "EMZ8EUmrC6",
"timeZone": "America/Los_Angeles",
"deviceToken": "55097f4ceca541cc5b02b5852d96d10c8238f147c3ec53c3e8a44bfc66520e41",
"deviceType": "ios",
"appVersion": "1",
"appName": "myAppName",
"channels": [
"global"
],
"installationId": "ae540abe-21d4-446f-b90f-f5b6bec04109",
"appIdentifier": "myAppIdentifier",
"parseVersion": "1.14.2",
"localeIdentifier": "en-US",
"badge": 0,
"_created_at": {
"$date": "2017-05-19T06:03:14.614Z"
},
"_updated_at": {
"$date": "2017-05-19T06:03:14.614Z"
}
}
_User
{
"_id": "ZEMtqdJMaw",
"_p_installationKey": "_Installation$EMZ8EUmrC6",
"username": "121259958664",
"_hashed_password": "$2a$10$HR6TtUFB5G3tkeA9LlHbvuKOE2rpG.gvyHqAjsOQBps.X9jQvu9DO",
"_wperm": [
"ZEMtqdJMaw"
],
"_rperm": [
"*",
"ZEMtqdJMaw"
],
"_acl": {
"ZEMtqdJMaw": {
"w": true,
"r": true
},
"*": {
"r": true
}
},
"_created_at": {
"$date": "2017-05-19T06:03:27.637Z"
},
"_updated_at": {
"$date": "2017-05-19T06:03:27.637Z"
}
}
Config Vars in Heroku
main.js
// iOS push testing
Parse.Cloud.define("iosPushTest", function(request, response) {
// request has 2 parameters: params passed by the client and the authorized user
var params = request.params;
var user = request.user;
// Our "Message" class has a "text" key with the body of the message itself
var messageText = params.text;
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo('deviceType', 'ios'); // targeting iOS devices only
Parse.Push.send({
where: pushQuery, // Set our Installation query
data: {
alert: "Message: " + messageText
}
}, { success: function() {
console.log("#### PUSH OK");
response.success('success');
}, error: function(error) {
console.log("#### PUSH ERROR" + error.message);
response.error('failed');
}, useMasterKey: true});
});
index.js
var devCertPath = path.resolve(__dirname, 'ParsePushDevelopmentCertificate.p12');
var pushConfig = {'ios': [
{
pfx: devCertPath, // P12 file only
bundleId: 'myBundleId', // change to match bundleId
production: false // dev certificate
}
]
};
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'myAppId',
masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
},
push: pushConfig
});
Logs
at Object.onceWrapper (events.js:293:19)
2017-05-19T18:06:04.498577+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:06:04.498577+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:06:04.498578+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:06:04.498579+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9)
2017-05-19T18:06:04.498579+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:06:04.501023+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
2017-05-19T18:06:04.501397+00:00 app[web.1]: Fri, 19 May 2017 18:06:04 GMT apn Socket closed undefined
2017-05-19T18:06:04.501480+00:00 app[web.1]: Fri, 19 May 2017 18:06:04 GMT apn Removing socket from pool undefined
2017-05-19T18:06:04.501686+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2017-05-19T18:06:04.501787+00:00 app[web.1]: Fri, 19 May 2017 18:06:04 GMT apn 1 left to send
2017-05-19T18:06:20.502222+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn Initialising connection
2017-05-19T18:06:20.502541+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn 1 left to send
2017-05-19T18:06:20.611635+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn Socket error occurred undefined { Error: socket hang up
2017-05-19T18:06:20.611637+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:06:20.611638+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:06:20.611639+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:06:20.611652+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:06:20.611653+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:06:20.611654+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:06:20.611655+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9) code: 'ECONNRESET' }
2017-05-19T18:06:20.611802+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn Destroying connection undefined
2017-05-19T18:06:20.611886+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn Removing socket from pool undefined
2017-05-19T18:06:20.612721+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn Raising error: { Error: socket hang up
2017-05-19T18:06:20.612723+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:06:20.612724+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:06:20.612724+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:06:20.612725+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:06:20.612725+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:06:20.612726+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:06:20.612727+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9) code: 'ECONNRESET' } undefined undefined
2017-05-19T18:06:20.612870+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn Error occurred with trace: Error: socket hang up
2017-05-19T18:06:20.612871+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:06:20.612872+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:06:20.612872+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:06:20.612873+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:06:20.612873+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:06:20.612874+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:06:20.612875+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9)
2017-05-19T18:06:20.613192+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
2017-05-19T18:06:20.613647+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn Socket closed undefined
2017-05-19T18:06:20.613741+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn Removing socket from pool undefined
2017-05-19T18:06:20.624646+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2017-05-19T18:06:20.624800+00:00 app[web.1]: Fri, 19 May 2017 18:06:20 GMT apn 1 left to send
2017-05-19T18:06:52.614568+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Initialising connection
2017-05-19T18:06:52.614810+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn 1 left to send
2017-05-19T18:06:52.758861+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Socket error occurred undefined { Error: socket hang up
2017-05-19T18:06:52.758864+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:06:52.758865+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:06:52.758866+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:06:52.758866+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:06:52.758867+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:06:52.758868+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:06:52.758869+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9) code: 'ECONNRESET' }
2017-05-19T18:06:52.759154+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Destroying connection undefined
2017-05-19T18:06:52.759277+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Removing socket from pool undefined
2017-05-19T18:06:52.759717+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Raising error: { Error: socket hang up
2017-05-19T18:06:52.759719+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:06:52.759720+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:06:52.759720+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:06:52.759721+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:06:52.759722+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:06:52.759722+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:06:52.759723+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9) code: 'ECONNRESET' } undefined undefined
2017-05-19T18:06:52.759875+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Error occurred with trace: Error: socket hang up
2017-05-19T18:06:52.759876+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:06:52.759877+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:06:52.759878+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:06:52.759878+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:06:52.759879+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:06:52.759880+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:06:52.759880+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9)
2017-05-19T18:06:52.760240+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
2017-05-19T18:06:52.760741+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Socket closed undefined
2017-05-19T18:06:52.760851+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Removing socket from pool undefined
2017-05-19T18:06:52.761152+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2017-05-19T18:06:52.761244+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn 1 left to send
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-05-19T18:06:52.759877+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:06:52.759878+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:06:52.759878+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:06:52.759879+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:06:52.759880+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:06:52.759880+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9)
2017-05-19T18:06:52.760240+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
2017-05-19T18:06:52.760741+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Socket closed undefined
2017-05-19T18:06:52.760851+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn Removing socket from pool undefined
2017-05-19T18:06:52.761152+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2017-05-19T18:06:52.761244+00:00 app[web.1]: Fri, 19 May 2017 18:06:52 GMT apn 1 left to send
2017-05-19T18:07:42.422486+00:00 heroku[router]: at=info method=POST path="/parse/push" host=spottune.herokuapp.com request_id=4ebb4912-b4d5-42bd-8057-21cb23763300 fwd="54.204.64.16" dyno=web.1 connect=0ms service=18ms status=200 bytes=533 protocol=https
2017-05-19T18:07:42.368169+00:00 app[web.1]: [36mverbose[39m: REQUEST for [POST] /parse/functions/iosPushTest: {
2017-05-19T18:07:42.368182+00:00 app[web.1]: "text": "Testing"
2017-05-19T18:07:42.368186+00:00 app[web.1]: } method=POST, url=/parse/functions/iosPushTest, host=myapp.herokuapp.com, connection=close, x-parse-app-display-version=1.0, x-parse-application-id=applicationID, accept=*/*, accept-language=en-us, x-parse-os-version=10.3.2 (14F5080a), user-agent=Spottunes/1 CFNetwork/811.5.3 Darwin/16.6.0, x-parse-app-build-version=1, content-type=application/json; charset=utf-8, x-parse-session-token=r:d574da7c3405de7c7cad42c147bcec85, x-parse-client-version=i1.14.2, x-parse-installation-id=ae540abe-21d4-446f-b90f-f5b6bec04109, accept-encoding=gzip, deflate, x-request-id=1d2c625e-2d55-4270-b9b0-9b3c74ea457d, x-forwarded-for=128.54.116.32, x-forwarded-proto=https, x-forwarded-port=443, via=1.1 vegur, connect-time=0, x-request-start=1495217262279, total-route-time=0, content-length=18, text=Testing
2017-05-19T18:07:42.409208+00:00 app[web.1]: [36mverbose[39m: REQUEST for [POST] /parse/push: {
2017-05-19T18:07:42.409211+00:00 app[web.1]: "where": {
2017-05-19T18:07:42.409212+00:00 app[web.1]: "deviceType": "ios"
2017-05-19T18:07:42.409213+00:00 app[web.1]: },
2017-05-19T18:07:42.409214+00:00 app[web.1]: "data": {
2017-05-19T18:07:42.409214+00:00 app[web.1]: "alert": "Message: Testing"
2017-05-19T18:07:42.409215+00:00 app[web.1]: }
2017-05-19T18:07:42.409218+00:00 app[web.1]: } method=POST, url=/parse/push, host=myapp.herokuapp.com, connection=close, user-agent=node-XMLHttpRequest, Parse/js1.9.2 (NodeJS 7.10.0), accept=*/*, content-type=text/plain, x-request-id=4ebb4912-b4d5-42bd-8057-21cb23763300, x-forwarded-for=54.204.64.16, x-forwarded-proto=https, x-forwarded-port=443, via=1.1 vegur, connect-time=0, x-request-start=1495217262403, total-route-time=0, content-length=237, deviceType=ios, alert=Message: Testing
2017-05-19T18:07:42.410004+00:00 app[web.1]: [33mwarn[39m: Trying to schedule a push while server is not configured.
2017-05-19T18:07:42.410267+00:00 app[web.1]: [33mwarn[39m: Push will be sent immediately
2017-05-19T18:07:42.420038+00:00 app[web.1]: [36mverbose[39m: RESPONSE from [POST] /parse/push: {
2017-05-19T18:07:42.420040+00:00 app[web.1]: "headers": {
2017-05-19T18:07:42.420041+00:00 app[web.1]: "X-Parse-Push-Status-Id": "OBtnkjGpL8"
2017-05-19T18:07:42.420042+00:00 app[web.1]: },
2017-05-19T18:07:42.420043+00:00 app[web.1]: "response": {
2017-05-19T18:07:42.420043+00:00 app[web.1]: "result": true
2017-05-19T18:07:42.420044+00:00 app[web.1]: }
2017-05-19T18:07:42.420044+00:00 app[web.1]: } X-Parse-Push-Status-Id=OBtnkjGpL8, result=true
2017-05-19T18:07:42.428718+00:00 app[web.1]: #### PUSH OK
2017-05-19T18:07:42.429322+00:00 app[web.1]: [32minfo[39m: Ran cloud function iosPushTest for user ZEMtqdJMaw with:
2017-05-19T18:07:42.429324+00:00 app[web.1]: Input: {"text":"Testing"}
2017-05-19T18:07:42.429325+00:00 app[web.1]: Result: "success" functionName=iosPushTest, text=Testing, user=ZEMtqdJMaw
2017-05-19T18:07:42.430053+00:00 app[web.1]: [36mverbose[39m: RESPONSE from [POST] /parse/functions/iosPushTest: {
2017-05-19T18:07:42.430054+00:00 app[web.1]: "response": {
2017-05-19T18:07:42.430055+00:00 app[web.1]: "result": "success"
2017-05-19T18:07:42.430056+00:00 app[web.1]: }
2017-05-19T18:07:42.430056+00:00 app[web.1]: } result=success
2017-05-19T18:07:42.433082+00:00 app[web.1]: [36mverbose[39m: _PushStatus OBtnkjGpL8: sending push to 1 installations
2017-05-19T18:07:42.458687+00:00 app[web.1]: Fri, 19 May 2017 18:07:42 GMT apn 2 left to send
2017-05-19T18:07:42.432839+00:00 heroku[router]: at=info method=POST path="/parse/functions/iosPushTest" host=spottune.herokuapp.com request_id=1d2c625e-2d55-4270-b9b0-9b3c74ea457d fwd="128.54.116.32" dyno=web.1 connect=0ms service=151ms status=200 bytes=502 protocol=https
2017-05-19T18:07:56.765036+00:00 app[web.1]: Fri, 19 May 2017 18:07:56 GMT apn Initialising connection
2017-05-19T18:07:56.767442+00:00 app[web.1]: Fri, 19 May 2017 18:07:56 GMT apn 2 left to send
2017-05-19T18:07:57.045303+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Socket error occurred undefined { Error: socket hang up
2017-05-19T18:07:57.045317+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:07:57.045318+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:07:57.045318+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:07:57.045319+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:07:57.045319+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:07:57.045320+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:07:57.045320+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9) code: 'ECONNRESET' }
2017-05-19T18:07:57.045416+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Destroying connection undefined
2017-05-19T18:07:57.045473+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Removing socket from pool undefined
2017-05-19T18:07:57.045796+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Raising error: { Error: socket hang up
2017-05-19T18:07:57.045797+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:07:57.045797+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:07:57.045798+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:07:57.045798+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:07:57.045799+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:07:57.045799+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:07:57.045800+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9) code: 'ECONNRESET' } undefined undefined
2017-05-19T18:07:57.045910+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Error occurred with trace: Error: socket hang up
2017-05-19T18:07:57.045912+00:00 app[web.1]: at TLSSocket.onHangUp (_tls_wrap.js:1120:19)
2017-05-19T18:07:57.045912+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:07:57.045913+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:07:57.045914+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:07:57.045914+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:07:57.045915+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:07:57.045916+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9)
2017-05-19T18:07:57.046198+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
2017-05-19T18:07:57.046589+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Socket closed undefined
2017-05-19T18:07:57.046677+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Removing socket from pool undefined
2017-05-19T18:07:57.046816+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2017-05-19T18:07:57.046889+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn 2 left to send
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-05-19T18:07:57.045912+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:07:57.045913+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:07:57.045914+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:07:57.045914+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:07:57.045915+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:07:57.045916+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9)
2017-05-19T18:07:57.046198+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
2017-05-19T18:07:57.046589+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Socket closed undefined
2017-05-19T18:07:57.046677+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Removing socket from pool undefined
2017-05-19T18:07:57.046816+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2017-05-19T18:07:57.046889+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn 2 left to send
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...
2017-05-19T18:07:57.045912+00:00 app[web.1]: at Object.onceWrapper (events.js:293:19)
2017-05-19T18:07:57.045913+00:00 app[web.1]: at emitNone (events.js:91:20)
2017-05-19T18:07:57.045914+00:00 app[web.1]: at TLSSocket.emit (events.js:188:7)
2017-05-19T18:07:57.045914+00:00 app[web.1]: at endReadableNT (_stream_readable.js:975:12)
2017-05-19T18:07:57.045915+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-19T18:07:57.045916+00:00 app[web.1]: at process._tickDomainCallback (internal/process/next_tick.js:128:9)
2017-05-19T18:07:57.046198+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
2017-05-19T18:07:57.046589+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Socket closed undefined
2017-05-19T18:07:57.046677+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn Removing socket from pool undefined
2017-05-19T18:07:57.046816+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2017-05-19T18:07:57.046889+00:00 app[web.1]: Fri, 19 May 2017 18:07:57 GMT apn 2 left to send
Call using Swift
print("sending push notification...")
let param: [String: Any] = [
"text" : "Testing"
]
PFCloud.callFunction(inBackground: "iosPushTest", withParameters: param) { (response, error) in
print("push \(response)")
}
Xcode console
sending push notification...
push Optional(success)
Not sure what else should I add in order to make this work. Any help is appreciated
I don't see a file path to your APNS cert in your configs. That needs to be included, and there is a little bit of extra configuration to do in your index.js to enable Push. Not sure how it's hadnled when you call Push.send() without the extra configuration enabled, but that looks to be going through. So, my bet is invalid APNS. If you debug this locally, you'd likely get some more useful server output.

Heroku Deployment Issues with Postgres and Sequelize

I am trying to deploy my app to Heroku. It works perfectly fine when run locally. From the moment I deployed it (deploying through github integration) I received the generic Application Error screen. Below are my heroku logs. These actually run three times but there was no point in me posting the same thing three times. They always end with:
2017-05-02T14:59:26.033702+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-crag-40902.herokuapp.com request_id=6b64883e-9697-4d58-84d9-2f173d5b4cb1 fwd="70.
54.76.222" dyno= connect= service= status=503 bytes= protocol=https
2017-05-02T14:59:27.425435+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-crag-40902.herokuapp.com request_id=d3719d8f-4670-4621-a044-a511ee6884
10 fwd="70.54.76.222" dyno= connect= service= status=503 bytes= protocol=https
This will print 2 to 4 times after each consecutive error screen. The first error is regarding the .env files not running and the second is trying to connect to sequelize. My primary focus is sorting out the .env because if that is sorted out, at least the app will show my app will be visible.
.env error:
{ Error: ENOENT: no such file or directory, open '.env'
2017-05-02T16:09:39.622865+00:00 app[web.1]: at Error (native)
2017-05-02T16:09:39.622866+00:00 app[web.1]: at Object.fs.openSync (fs.js:641:18)
2017-05-02T16:09:39.622867+00:00 app[web.1]: at Object.fs.readFileSync (fs.js:509:33)
2017-05-02T16:09:39.622867+00:00 app[web.1]: at Object.config (/app/node_modules/dotenv/lib/main.js:30:37)
2017-05-02T16:09:39.622868+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:3:19)
2017-05-02T16:09:39.622869+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-05-02T16:09:39.622869+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-05-02T16:09:39.622870+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-05-02T16:09:39.622871+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-05-02T16:09:39.622871+00:00 app[web.1]: at Function.Module._load (module.js:438:3) errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
2017-05-02T16:09:40.242885+00:00 app[web.1]: Unhandled rejection
Sequelize error:
SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5432
2017-05-02T16:09:40.242902+00:00 app[web.1]: at /app/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:98:20
2017-05-02T16:09:40.242903+00:00 app[web.1]: at Connection.<anonymous> (/app/node_modules/pg/lib/client.js:186:5)
2017-05-02T16:09:40.242904+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-05-02T16:09:40.242905+00:00 app[web.1]: at Connection.emit (events.js:188:7)
2017-05-02T16:09:40.242905+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/pg/lib/connection.js:86:10)
2017-05-02T16:09:40.242906+00:00 app[web.1]: at emitOne (events.js:96:13)
2017-05-02T16:09:40.242907+00:00 app[web.1]: at emitErrorNT (net.js:1281:8)
2017-05-02T16:09:40.242907+00:00 app[web.1]: at Socket.emit (events.js:188:7)
2017-05-02T16:09:40.242909+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:104:9)
2017-05-02T16:09:40.242908+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:80:11)
2017-05-02T16:09:40.360035+00:00 heroku[web.1]: Process exited with status 0
2017-05-02T16:09:40.373996+00:00 heroku[web.1]: State changed from starting to crashed
This is my index.js:
'use strict';
const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(module.filename);
const env = process.env.NODE_ENV || 'development';
const config = require(__dirname + '/../config/config.json')[env];
const db = {};
if (config.use_env_variable) {
const sequelize = new Sequelize(process.env[config.use_env_variable]);
} else {
const sequelize = new Sequelize(config.database, config.username, config.password, config);
}
fs
.readdirSync(__dirname)
.filter((file) => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.forEach((file) => {
const model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
});
Object.keys(db).forEach((modelName) => {
if (db[modelName].associate) {
db[modelName].associate(db);
}
});
db.sequelize = sequelize;
db.Sequelize = Sequelize;
module.exports = db;
config.json:
{
"development": {
"username": "",
"password": "",
"database": "late_file",
"host": "127.0.0.1",
"dialect": "postgres"
},
"test": {
"username": "",
"password": "",
"database": "database_test",
"host": "127.0.0.1",
"dialect": "postgres"
},
"production": {
"use_env_variable": "DATABASE_URL",
"dialect": "postgres"
}
}
.env, modified to exclude specific names of things
DB_HOST=localhost
DB_USER=
DB_PASS=
DB_NAME=
DB_SSL=true if heroku
DB_PORT=5432
DATABASE_URL=postgres://appropriate/url
applicable part of server.js
const pg = require('pg');
pg.defaults.ssl = true;
pg.connect(process.env.DATABASE_URL, function(err, client) {
if (err) throw err;
console.log('Connected to postgres! Getting schemas...');
client
.query('SELECT table_schema,table_name FROM information_schema.tables;')
.on('row', function(row) {
console.log(JSON.stringify(row));
});
});
Any help would be greatly appreciated!
Thanks in advance for anyone who offers any support!
Brandon,
I am running an app on Heroku using JAWS_DB and MySQL, but otherwise identical config.json and index.js. In my case on Heroku, the "if (config.use_env_variable) {const sequelize = new Sequelize(process.env[config.use_env_variable])" statement connects to the database without error. The logs appear to point to the "pg.connect" failing in server.js. It's not clear to me (without seeing the rest of your code) why you need to connect to the database in index.js, and then connect again in server.js. If you can remove the connection from pg.connect and try to run with just the connection from index.js it may stop this error.