I have an app, created in meteor.js but it shouldn't be important i think. I have also mongo cluster on mongo atlas. So far during development i connected to db by connection string without problem from my local machine. However when i created linux machine on DigitalOcean and tried to connect my app using same connection string mongodb+srv://<user>:<password>#xyz.mongodb.net/<dbName>?retryWrites=true&w=majority
I got the following error.
MongoNetworkError: failed to connect to server [xyz.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to xyz.mongodb.net:27017 closed
at TLSSocket.<anonymous> (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:440:9)
at Object.onceWrapper (events.js:421:26)
at TLSSocket.emit (events.js:314:20)
at TLSSocket.EventEmitter.emit (domain.js:483:12)
at net.js:675:12
at TCP.done (_tls_wrap.js:568:7)]
at Pool.<anonymous> (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/topologies/server.js:438:11)
at Pool.emit (events.js:314:20)
at Pool.EventEmitter.emit (domain.js:483:12)
at /home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:562:14
at /home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:1009:9
at callback (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:75:5)
at /home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connect.js:101:9
at _callback (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:329:7)
at Connection.errorHandler (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:344:7)
at Object.onceWrapper (events.js:421:26)
at Connection.emit (events.js:314:20)
at Connection.EventEmitter.emit (domain.js:483:12)
at TLSSocket.<anonymous> (/home/ubuntu/staging/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:438:12)
at Object.onceWrapper (events.js:421:26)
at TLSSocket.emit (events.js:314:20)
at TLSSocket.EventEmitter.emit (domain.js:483:12)
Do you have any idea of what could be wrong with me server config? I guess it is server config as on other machine same connection string works.
I had an heroku app has been running on there for the pass 5 years, and I have not doing any deployment for a while.
Only recently I saw there were two auto update by heroku postgres addon itself
Then from today, I try to go to my app as usual, try to do login, but failed as the app error log is saying not able to connect to postgres DB anymore. Please see these error, and my spring bean setting for DB connection (this setting has been there for 5 years unchanged, suddenly all stop working...)
I am wondering has anyone else encountered this issue recently? is it due to heroku major upgrade?
Please advise an solution if possible
Thanks
=================================================================
I have attached error log here:
2021-02-26T17:18:50.688282+00:00 app[web.1]: Feb 26, 2021 5:18:50 PM org.apache.catalina.core.StandardWrapperValve invoke
2021-02-26T17:18:50.688302+00:00 app[web.1]: SEVERE: Servlet.service() for servlet [mvc-dispatcher] in context with path [/] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection] with root cause
2021-02-26T17:18:50.688304+00:00 app[web.1]: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host "35.175.150.172", user "hazpvnhqxtodzl", database "d7fhtbev11bt6m", SSL off
2021-02-26T17:18:50.688305+00:00 app[web.1]: at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:293)
2021-02-26T17:18:50.688306+00:00 app[web.1]: at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
2021-02-26T17:18:50.688307+00:00 app[web.1]: at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
2021-02-26T17:18:50.688307+00:00 app[web.1]: at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
2021-02-26T17:18:50.688308+00:00 app[web.1]: at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
2021-02-26T17:18:50.688308+00:00 app[web.1]: at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
2021-02-26T17:18:50.688308+00:00 app[web.1]: at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:32)
2021-02-26T17:18:50.688309+00:00 app[web.1]: at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
2021-02-26T17:18:50.688310+00:00 app[web.1]: at org.postgresql.Driver.makeConnection(Driver.java:393)
2021-02-26T17:18:50.688311+00:00 app[web.1]: at org.postgresql.Driver.connect(Driver.java:267)
2021-02-26T17:18:50.688311+00:00 app[web.1]: at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
2021-02-26T17:18:50.688312+00:00 app[web.1]: at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
2021-02-26T17:18:50.688312+00:00 app[web.1]: at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
2021-02-26T17:18:50.688313+00:00 app[web.1]: at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
2021-02-26T17:18:50.688313+00:00 app[web.1]: at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
2021-02-26T17:18:50.688314+00:00 app[web.1]: at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
2021-02-26T17:18:50.688316+00:00 app[web.1]: at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:71)
2021-02-26T17:18:50.688316+00:00 app[web.1]: at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
2021-02-26T17:18:50.688317+00:00 app[web.1]: at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
2021-02-26T17:18:50.688317+00:00 app[web.1]: at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:160)
2021-02-26T17:18:50.688318+00:00 app[web.1]: at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:81)
2021-02-26T17:18:50.688318+00:00 app[web.1]: at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
2021-02-26T17:18:50.688318+00:00 app[web.1]: at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:60)
2021-02-26T17:18:50.688319+00:00 app[web.1]: at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70)
2021-02-26T17:18:50.688320+00:00 app[web.1]: at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:61)
2021-02-26T17:18:50.688320+00:00 app[web.1]: at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:377)
2021-02-26T17:18:50.688321+00:00 app[web.1]: at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
2021-02-26T17:18:50.688321+00:00 app[web.1]: at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:417)
2021-02-26T17:18:50.688322+00:00 app[web.1]: at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:255)
2021-02-26T17:18:50.688322+00:00 app[web.1]: at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
2021-02-26T17:18:50.688323+00:00 app[web.1]: at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
2021-02-26T17:18:50.688323+00:00 app[web.1]: at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
2021-02-26T17:18:50.688324+00:00 app[web.1]: at com.sun.proxy.$Proxy34.listTillReportHistory(Unknown Source)
2021-02-26T17:18:50.688324+00:00 app[web.1]: at com.lsinternal.restfulservice.ApiTill.reportTillHistory(ApiTill.java:75)
2021-02-26T17:18:50.688325+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2021-02-26T17:18:50.688325+00:00 app[web.1]: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2021-02-26T17:18:50.688326+00:00 app[web.1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2021-02-26T17:18:50.688326+00:00 app[web.1]: at java.lang.reflect.Method.invoke(Method.java:607)
2021-02-26T17:18:50.688333+00:00 app[web.1]: at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
2021-02-26T17:18:50.688335+00:00 app[web.1]: at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
2021-02-26T17:18:50.688336+00:00 app[web.1]: at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
2021-02-26T17:18:50.688337+00:00 app[web.1]: at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743)
2021-02-26T17:18:50.688337+00:00 app[web.1]: at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672)
2021-02-26T17:18:50.688338+00:00 app[web.1]: at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82)
2021-02-26T17:18:50.688338+00:00 app[web.1]: at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)
2021-02-26T17:18:50.688339+00:00 app[web.1]: at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)
2021-02-26T17:18:50.688339+00:00 app[web.1]: at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
2021-02-26T17:18:50.688340+00:00 app[web.1]: at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
2021-02-26T17:18:50.688340+00:00 app[web.1]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
2021-02-26T17:18:50.688341+00:00 app[web.1]: at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
2021-02-26T17:18:50.688341+00:00 app[web.1]: at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
2021-02-26T17:18:50.688342+00:00 app[web.1]: at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
2021-02-26T17:18:50.688342+00:00 app[web.1]: at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
2021-02-26T17:18:50.688343+00:00 app[web.1]: at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
Also, the config of my DB connection in spring xml config file:
<bean class="java.net.URI" id="dbUrl">
<constructor-arg value="#{systemEnvironment['DATABASE_URL']}"/>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="url" value="#{ 'jdbc:postgresql://' + #dbUrl.getHost() + ':' + #dbUrl.getPort() + #dbUrl.getPath() + '?sslmode=require' }"/>
<property name="username" value="#{ #dbUrl.getUserInfo().split(':')[0] }"/>
<property name="password" value="#{ #dbUrl.getUserInfo().split(':')[1] }"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<!-- change this to 'verify' before running as a production app -->
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
it is absolutely identical to this tutorial -> https://devcenter.heroku.com/articles/heroku-postgresql#spring-xml
I have been trying to solve the issue in the pass 3 days, really ran out of idea now... please advise if possible
Thanks
Looks like this one:
Seeing "FATAL: no pg_hba.conf entry" errors in Postgres
Issue
I'm seeing "no pg_hba.conf entry for host" errors:
sql_error_code = 28000 FATAL: no pg_hba.conf entry for host "122.180.247.11", user "u3idolso5k2v83", database "dc85788d13v9ej", SSL off
Resolution
"FATAL: no pg_hba.conf entry for host" errors indicate that there was a failed authentication attempt to the database, so the connection couldn't be established. This can happen because of different reasons:
The authentication failed because the user/password credentials were invalid: ((user "xxxx", database "yyyy")). This could happen if you're trying to connect to the database using wrong or revoked credentials. (See also: Why am I seeing connection errors for my Heroku Postgres database from an unexpected IP address?).
The authentication failed because the connection didn't use SSL encryption: (SSL off). All Heroku Postgres production databases require using SSL connections to ensure that communications between applications and the database remain secure. If your client is not using SSL to connect to your database, you would see these errors even if you're using the right credentials to connect to it.
"I think" here SSL OFF is the case/(at least also) true. (Please rather copy&paste logs, than screen-shoting 'em!)
-> (2):
Most clients will connect over SSL by default, but on occasion it is necessary to set the sslmode=require parameter on a Postgres connection. Please add this parameter in code rather than editing the config var directly. Please check you are enforcing use of SSL especially if you are using Java or Node.js clients.
...
It is also important that you use a version of the Postgres JDBC driver verion 9.2 or greater. For example, in Maven add this to your pom.xml:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.1</version>
</dependency>
...
The DATABASE_URL for the Heroku Postgres add-on follows this naming convention:
postgres://<username>:<password>#<host>/<dbname>
However the Postgres JDBC driver uses the following convention:
jdbc:postgresql://<host>:<port>/<dbname>?sslmode=require&user=<username>&password=<password>
If you navigate to your Database Credentials in your panel, Heroku says:
Please note that these credentials are not permanent. Heroku rotates
credentials periodically and updates applications where this database
is attached.
I recommend you check your credentials again, maybe it has changed.
Suddenly I got an issue in running process of apache kafka consumer group.
Anyone please share your thoughts on why this issue happens.
NestedError: topic/partition change check failed
at _checkTopicPartitionChange (<system-path>/node_modules/kafka-node/lib/consumerGroup.js:295:37)
at client.loadMetadataForTopics (<system-path>/node_modules/kafka-node/lib/consumerGroup.js:323:14)
at async.series (<system-path>/node_modules/kafka-node/lib/kafkaClient.js:919:7)
at <system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:3888:9
at <system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:473:16
at iterateeCallback (<system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:988:17)
at <system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:969:16
at <system-path>/node_modules/kafka-node/node_modules/async/dist/async.js:3885:13
at Timeout.setTimeout [as _onTimeout] (<system-path>/node_modules/kafka-node/lib/kafkaClient.js:491:5)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
Caused By: TimeoutError: Request timed out after 30000ms
at new TimeoutError (<system-path>/node_modules/kafka-node/lib/errors/TimeoutError.js:6:9)
at Timeout.setTimeout [as _onTimeout] (<system-path>/node_modules/kafka-node/lib/kafkaClient.js:491:14)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
(node:12516) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Any help would be appreciable.
Error: connection refused: localtunnel.me:37244 (check your firewall settings)
your url is: https://pretty-skun-91.localtunnel.me
/usr/lib/node_modules/localtunnel/bin/client:65
throw err;
^
Error: connection refused: localtunnel.me:37244 (check your firewall settings)
at Socket.<anonymous> (/usr/lib/node_modules/localtunnel/lib/TunnelCluster.js:47:32)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:66:8)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickCallback (internal/process/next_tick.js:181:9)
I keep getting errors like this...
app[web.1]: Configuration error: Configuration error[Cannot connect to database [default]]
app[web.1]: at scala.collection.immutable.List.foreach(List.scala:381)
app[web.1]: Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "lcnjgrwbmbffwv"
app[web.1]: at play.core.StaticApplication.<init>(ApplicationProvider.scala:55)
app[web.1]: at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:408)
app[web.1]: at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
app[web.1]: at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
app[web.1]: at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
app[web.1]: at org.postgresql.Driver.makeConnection(Driver.java:410)
app[web.1]: at java.sql.DriverManager.getConnection(DriverManager.java:664)
app[web.1]: at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:363)
app[web.1]: at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:240)
app[web.1]: at java.sql.DriverManager.getConnection(DriverManager.java:247)
app[web.1]: at org.postgresql.Driver.connect(Driver.java:280)
app[web.1]: at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
app[web.1]: at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:120)
app[web.1]: at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
app[web.1]: ... 18 more
heroku[web.1]: Process exited with status 255
Not just in Heroku, but when I run my Play app with a user whose name is different than the default user name in the database.
My Play Framework "application.conf" is like this...
db.default.username="nameOfDatabaseUser"
db.default.password="passOfDatabaseUser"
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://urlofdatabase:5432/name_of_database"
Here's the thing. When my terminal user is named "nameOfDatabaseUser", it works. But when my terminal user has a different name, it connects to the database as the name of the current Linux terminal user.
In the above case it appears that Heroku tried to connect as a user lcnjgrwbmbffwv and there was no user lcnjgrwbmbffwv in the database.
How do I specify the default database username so that it doesn't use my terminal username?
The correct key to specify the user is db.default.user, not db.default.username.