grishka / Smithereen

Federated, ActivityPub-compatible social network server with friends, walls, and groups.
The Unlicense
385 stars 30 forks source link

web container can't find mysql container #57

Closed kgilpin closed 1 year ago

kgilpin commented 1 year ago

Starting the project with the provided docker-compose.yml, I'm stuck on the following issue.

MySQL reports ready and OK:

smithereen-mysql-1     | 2023-05-15T17:36:40.214471Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
smithereen-mysql-1     | 2023-05-15T17:36:40.220184Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.33'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

The web container can't seem to find the database:

View stack trace ⬇️ ``` smithereen-web-1 | Exception in thread "main" java.lang.RuntimeException: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure smithereen-web-1 | smithereen-web-1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. smithereen-web-1 | at smithereen.SmithereenApplication.main(SmithereenApplication.java:106) smithereen-web-1 | Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure smithereen-web-1 | smithereen-web-1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. smithereen-web-1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) smithereen-web-1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) smithereen-web-1 | at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) smithereen-web-1 | at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681) smithereen-web-1 | at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229) smithereen-web-1 | at smithereen.storage.DatabaseConnectionManager.getConnection(DatabaseConnectionManager.java:30) smithereen-web-1 | at smithereen.Config.loadFromDatabase(Config.java:124) smithereen-web-1 | at smithereen.SmithereenApplication.main(SmithereenApplication.java:103) smithereen-web-1 | Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure smithereen-web-1 | smithereen-web-1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. smithereen-web-1 | at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) smithereen-web-1 | at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) smithereen-web-1 | at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) smithereen-web-1 | at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) smithereen-web-1 | at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) smithereen-web-1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) smithereen-web-1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) smithereen-web-1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) smithereen-web-1 | at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) smithereen-web-1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91) smithereen-web-1 | at com.mysql.cj.NativeSession.connect(NativeSession.java:144) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826) smithereen-web-1 | ... 8 more smithereen-web-1 | Caused by: java.net.ConnectException: Connection refused smithereen-web-1 | at java.base/sun.nio.ch.Net.connect0(Native Method) smithereen-web-1 | at java.base/sun.nio.ch.Net.connect(Net.java:579) smithereen-web-1 | at java.base/sun.nio.ch.Net.connect(Net.java:568) smithereen-web-1 | at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588) smithereen-web-1 | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) smithereen-web-1 | at java.base/java.net.Socket.connect(Socket.java:633) smithereen-web-1 | at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) smithereen-web-1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) smithereen-web-1 | ... 11 more smithereen-web-1 exited with code 1 smithereen-web-1 | Exception in thread "main" java.lang.RuntimeException: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure smithereen-web-1 | smithereen-web-1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. smithereen-web-1 | at smithereen.SmithereenApplication.main(SmithereenApplication.java:106) smithereen-web-1 | Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure smithereen-web-1 | smithereen-web-1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. smithereen-web-1 | at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) smithereen-web-1 | at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:456) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) smithereen-web-1 | at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) smithereen-web-1 | at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681) smithereen-web-1 | at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229) smithereen-web-1 | at smithereen.storage.DatabaseConnectionManager.getConnection(DatabaseConnectionManager.java:30) smithereen-web-1 | at smithereen.Config.loadFromDatabase(Config.java:124) smithereen-web-1 | at smithereen.SmithereenApplication.main(SmithereenApplication.java:103) smithereen-web-1 | Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure smithereen-web-1 | smithereen-web-1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. smithereen-web-1 | at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) smithereen-web-1 | at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) smithereen-web-1 | at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) smithereen-web-1 | at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) smithereen-web-1 | at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) smithereen-web-1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) smithereen-web-1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) smithereen-web-1 | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) smithereen-web-1 | at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) smithereen-web-1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91) smithereen-web-1 | at com.mysql.cj.NativeSession.connect(NativeSession.java:144) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956) smithereen-web-1 | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826) smithereen-web-1 | ... 8 more smithereen-web-1 | Caused by: java.net.ConnectException: Connection refused smithereen-web-1 | at java.base/sun.nio.ch.Net.connect0(Native Method) smithereen-web-1 | at java.base/sun.nio.ch.Net.connect(Net.java:579) smithereen-web-1 | at java.base/sun.nio.ch.Net.connect(Net.java:568) smithereen-web-1 | at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588) smithereen-web-1 | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) smithereen-web-1 | at java.base/java.net.Socket.connect(Socket.java:633) smithereen-web-1 | at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) smithereen-web-1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) smithereen-web-1 | ... 11 more smithereen-web-1 exited with code 1 ```
grishka commented 1 year ago

Which config file are you using? You want the one that's specific to docker: https://github.com/grishka/Smithereen/blob/master/examples/config_docker.properties

kgilpin commented 1 year ago

Yes, I've just added the key and salt, and removed the dummy domain option.

➜  Smithereen git:(master) ✗ diff config.properties examples/config.properties
8a9
> domain=YOUR_DOMAIN_HERE
32,33c33,34
< imgproxy.key=e35370575394e3cb3140bf37657f7f861b4ea2f79ca394191268b7f01fc4c0a9
< imgproxy.salt=f398a7d4b1926924eee7d82d7f5dbf1f89b870ad23da2ed30353cf922a6c5827
---
> imgproxy.key=GENERATE YOUR OWN
> imgproxy.salt=GENERATE YOUR OWN
grishka commented 1 year ago

You're saying that you used the regular config.properties, aren't you? The non _docker one is for running Smithereen on the host OS without any form of containerization. You do need config_docker.properties, in particular db.host=mysql is the important part.

kgilpin commented 1 year ago

Got it! Thank you.

One correction I can make: In the README:

docker exec -it smithereen_web_1 bash -c ./smithereen-init-admin

What worked for me:

docker-compose exec web bash -c ./smithereen-init-admin

or

docker exec -it smithereen-web-1 bash -c ./smithereen-init-admin