'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.



Solution 1:[1]

It is about correct database connection configuration

In our case on heroku we set database url

postgres://xxx:[email protected]:5432/asdfasgsgbwev

And tlsConfig.certificateVerification = .none

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 imike