Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will not connect to gmail #299

Open
1 task done
Dvalin21 opened this issue Aug 28, 2024 · 5 comments
Open
1 task done

Will not connect to gmail #299

Dvalin21 opened this issue Aug 28, 2024 · 5 comments
Labels
Status: Created The issue has been created but not yet assigned or addressed. Type: Bug Something isn't working

Comments

@Dvalin21
Copy link

Avoid duplicated bug reports

  • I've found a bug and checked that there are no open or closed bug report related to this.

Description

  1. Set port for email and smtp.gmail.com, but tries to send out on port 25 causing failure to connect.
 2024/08/27 16:15:12 stdout	Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emailService' defined in URL [jar:file:/opt/app/backend/app.jar!/BOOT-INF/classes!/com/github/mdeluise/plantit/notification/email/EmailService.class]: Failed to instantiate [com.github.mdeluise.plantit.notification.email.EmailService]: Constructor threw exception
Caused by: com.github.mdeluise.plantit.notification.email.EmailException: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 25; timeout -1;

Local environment

ENV

#
# DB
#
MYSQL_HOST=db
MYSQL_PORT=3306
MYSQL_USERNAME=root
MYSQL_PSW=pass
MYSQL_DATABASE=bootdb
MYSQL_ROOT_PASSWORD=pass

#
# JWT
#
JWT_SECRET=secret
JWT_EXP=1

#
# Server config
#
USERS_LIMIT=-1 # less then 0 means no limit
UPLOAD_DIR=/upload-dir # path to the directory used to store uploaded images, if on docker deployment leave as it is and change the volume binding in the docker-compose file if needed
API_PORT=8080
FLORACODEX_URL=https://api.floracodex.com
FLORACODEX_KEY=key
ALLOWED_ORIGINS=* # CORS allowed origins (comma separated list)
LOG_LEVEL=DEBUG # could be: DEBUG, INFO, WARN, ERROR
CONTACT_MAIL=plantrus@address # address used as "contact" for template email
REMINDER_NOTIFY_CHECK=0 30 7 * * * # 6-values crontab expression to set the check time for reminders
MAX_REQUESTS_PER_MINUTE=100 # rate limiting of the upcoming requests
NTFY_ENABLED=true # if "false" ntfy service won't be available as notification dispatcher

#
# SSL
#
SSL_ENABLED=false
#CERTIFICATE_PATH=/certificates/ # path to files to use for ssl. If on docker deployment leave as it is and change the volume binding in the docker-compose file if needed

#
# Cache
#
CACHE_TTL=86400
CACHE_HOST=cache
CACHE_PORT=6379
CACHE_PASSWORD=password
CACHE_USERNAME=username

#
# SMTP
#
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_AUTH=true
SMTP_EMAIL=email address
SMTP_PASSWORD="pass"
SMTP_START_TTL=true

Compose

name: plant-it
services:
  server:
    image: msdeluise/plant-it-server:latest
    env_file: server.env
    depends_on:
      - db
      - cache
    restart: unless-stopped
    volumes:
      - "/volume1/docker/plantit/upload-dir:/upload-dir"
      - "/volume1/docker/plantit/certs:/certificates"
    ports:
      - "8881:8080"
      - "3066:3000"

  db:
    image: mysql:8.0
    restart: always
    env_file: server.env
    volumes:
      - "/volume1/docker/plantit/db:/var/lib/mysql"

  cache:
    image: redis:7.2.1
    restart: always
<h2 style="text-align: center; color: rgb(0, 0, 0); font-family: &quot;Lucida Console&quot;, Consola, Monaco, monospace, &quot;Courier New&quot;, Courier, serif; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">plant-it-server-1</h2>
date | stream | content
-- | -- | --
2024/08/27 22:16:31 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:31] "GET /assets/assets/images/logo.png HTTP/1.1" 304 -
2024/08/27 22:16:31 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:31] "GET /assets/AssetManifest.bin.json HTTP/1.1" 304 -
2024/08/27 22:16:30 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:30] "GET /assets/fonts/MaterialIcons-Regular.otf HTTP/1.1" 304 -
2024/08/27 22:16:30 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:30] "GET /assets/packages/iconsax_flutter/fonts/FlutterIconsax.ttf HTTP/1.1" 304 -
2024/08/27 22:16:30 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:30] "GET /assets/packages/cupertino_icons/assets/CupertinoIcons.ttf HTTP/1.1" 304 -
2024/08/27 22:16:30 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:30] "GET /assets/FontManifest.json HTTP/1.1" 304 -
2024/08/27 22:16:30 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:30] "GET /main.dart.js HTTP/1.1" 304 -
2024/08/27 22:16:30 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:30] "GET /flutter.js HTTP/1.1" 304 -
2024/08/27 22:16:30 | stderr | 192.168.112.1 - - [28/Aug/2024 03:16:30] "GET / HTTP/1.1" 304 -
2024/08/27 16:15:12 | stdout |  
2024/08/27 16:15:12 | stdout | ... 92 common frames omitted
2024/08/27 16:15:12 | stdout | at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2209) ~[jakarta.mail-1.0.0.jar!/:na]
2024/08/27 16:15:12 | stdout | at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:236) ~[jakarta.mail-1.0.0.jar!/:na]
2024/08/27 16:15:12 | stdout | at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:357) ~[jakarta.mail-1.0.0.jar!/:na]
2024/08/27 16:15:12 | stdout | at java.base/java.net.Socket.connect(Socket.java:686) ~[na:na]
2024/08/27 16:15:12 | stdout | at java.base/java.net.Socket.connect(Socket.java:751) ~[na:na]
2024/08/27 16:15:12 | stdout | at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[na:na]
2024/08/27 16:15:12 | stdout | at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:583) ~[na:na]
2024/08/27 16:15:12 | stdout | at java.base/sun.nio.ch.Net.connect(Net.java:578) ~[na:na]
2024/08/27 16:15:12 | stdout | at java.base/sun.nio.ch.Net.connect(Net.java:589) ~[na:na]
2024/08/27 16:15:12 | stdout | at java.base/sun.nio.ch.Net.connect0(Native Method) ~[na:na]
2024/08/27 16:15:12 | stdout | Caused by: java.net.ConnectException: Operation timed out
2024/08/27 16:15:12 | stdout | ... 88 common frames omitted
2024/08/27 16:15:12 | stdout | at com.github.mdeluise.plantit.notification.email.EmailService.checkConnection(EmailService.java:96) ~[classes!/:0.9.0]
2024/08/27 16:15:12 | stdout | at jakarta.mail.Service.connect(Service.java:222) ~[jakarta.mail-1.0.0.jar!/:na]
2024/08/27 16:15:12 | stdout | at jakarta.mail.Service.connect(Service.java:342) ~[jakarta.mail-1.0.0.jar!/:na]
2024/08/27 16:15:12 | stdout | at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:754) ~[jakarta.mail-1.0.0.jar!/:na]
2024/08/27 16:15:12 | stdout | at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2259) ~[jakarta.mail-1.0.0.jar!/:na]
2024/08/27 16:15:12 | stdout | Caused by: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 25; timeout -1
2024/08/27 16:15:12 | stdout | ... 83 common frames omitted
2024/08/27 16:15:12 | stdout | at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:210) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486) ~[na:na]
2024/08/27 16:15:12 | stdout | at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502) ~[na:na]
2024/08/27 16:15:12 | stdout | at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62) ~[na:na]
2024/08/27 16:15:12 | stdout | at com.github.mdeluise.plantit.notification.email.EmailService.<init>(EmailService.java:53) ~[classes!/:0.9.0]
2024/08/27 16:15:12 | stdout | at com.github.mdeluise.plantit.notification.email.EmailService.checkConnection(EmailService.java:101) ~[classes!/:0.9.0]
2024/08/27 16:15:12 | stdout | java.net.ConnectException: Operation timed out
2024/08/27 16:15:12 | stdout | nested exception is:
2024/08/27 16:15:12 | stdout | Caused by: com.github.mdeluise.plantit.notification.email.EmailException: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 25; timeout -1;
2024/08/27 16:15:12 | stdout | ... 81 common frames omitted
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:321) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:110) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:223) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.mdeluise.plantit.notification.email.EmailService]: Constructor threw exception
2024/08/27 16:15:12 | stdout | ... 67 common frames omitted
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.3.jar!/:6.0.3]
2024/08/27 16:15:12 | stdout | at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:312) ~[spring-beans-6.0.3.jar!/:6.0.3]

@Dvalin21 Dvalin21 added Status: Created The issue has been created but not yet assigned or addressed. Type: Bug Something isn't working labels Aug 28, 2024
@MDeLuise
Copy link
Owner

Hi there! I'm currently reviewing some older issues, and I wanted to check if this issue is still affecting you. With the latest release of the project (0.9.0), which includes numerous dependency updates and bug fixes, there's a chance the problem might have been resolved.

Could you please confirm whether you're still experiencing this issue on the latest version?

@Dvalin21
Copy link
Author

Dvalin21 commented Oct 22, 2024

Hi there! I'm currently reviewing some older issues, and I wanted to check if this issue is still affecting you. With the latest release of the project (0.9.0), which includes numerous dependency updates and bug fixes, there's a chance the problem might have been resolved.

Could you please confirm whether you're still experiencing this issue on the latest version?

Thanks for the response. Im no longer getting that error but the following

[error] | 1:08:51 175ms | Select at least one plant
[null, null]

I thought I had figured it out, but still getting this.

@Dvalin21 Dvalin21 reopened this Oct 22, 2024
@MDeLuise
Copy link
Owner

I've been trying to reproduce the issue locally but haven't been able to replicate it.
Could you confirm if you have enabled the app password for gmail and if you're inserting the app password? You can follow the steps here: Enable App Password.

There’s also another issue that might be related to this: Issue #139.

I’m continuing to inspect the problem.

@MDeLuise
Copy link
Owner

I'm continuing to inspect the issue, and based on my research ([1] [2] [3]), it seems that one possible cause could be related to antivirus software blocking the program from sending emails. Do you have any antivirus installed on your system?

@Dvalin21
Copy link
Author

I'm continuing to inspect the issue, and based on my research ([1] [2] [3]), it seems that one possible cause could be related to antivirus software blocking the program from sending emails. Do you have any antivirus installed on your system?

I just verified I was able to get auth code in email. Its possible I didn't wait for the container to finish doing what it needed maybe? Not sure. However, when I ran the container, it never did ask to put in a code to verify the account.
If it does help, I got this in the logs
Note: Yes, this is while using gmail for the email server.

server-1  | 2024-10-22T07:15:39.065Z  INFO 30 --- [           main] c.g.m.p.notification.email.EmailService  : SMTP successfully connected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Created The issue has been created but not yet assigned or addressed. Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants