I downloaded JHipster from git and tried to understand how to configure session timeout but couldn't find any web.xml or java-based class for that.
Could you please help me figure out how can I configure session timeout for example to be 20 min?
This is a Spring Boot configuration.
You can configure it in your application-*.yml file:
server:
port: 8080
address: localhost
sessionTimeout: 20000
in your application-*.yml file:
server:
port: 8080
address: localhost
sessionTimeout: 20000
is OK for 20 minutes but if you want to have more 30 minutes your access Token validity ("tokenValidityInSeconds" attribute) is 30 minutes by default. You can configue this attribute in application.yml file.
Example for 3 hours = 180 minutes = 10800 secondes:
authentication:
oauth:
clientid: testspsyapp
secret: mySecretOAuthSecret
# Token is valid 3 hours
tokenValidityInSeconds: 10800
Do not to forget the changes "sessionTimeout" attribut to your application-*.yml file :)
server:
port: 8080
address: localhost
sessionTimeout: 180000
I know this is an old question but the answer needed to be updated as the config setting being called is deprecated. You'll want to use this instead.
server:
port: 8080
servlet:
session:
timeout: 60s
Related
I want to send mail as a reminder in Admin Server
But get this error:
com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout 20000
...
I have searched a lot online but still don't work
My Admin Server Application YAML configuration file:
spring:
security:
user:
name: admin
password: 123456
boot:
admin:
notify:
mail:
enabled: true
# receivers
to: xxx#outlook.com
ignore-changes: {"UNKNOWN:UP"}
# copy-to list
cc:
from: Spring Boot Admin<xxx#gmail.com>
# mail sender
mail:
host: smtp.gmail.com
port: 587
username: xxx#gmail.com
# with 2-factor authentication, we should get app password from Google
password: my-app-password
default-encoding: UTF-8
properties:
mail:
smtp:
connectiontimeout: 20000
timeout: 20000
writetimeout: 20000
starttls:
enable: true
required: true
auth: true
ssl:
enable: true
required: true
debug: true
server:
port: 8081
I config the settings with the help of this instruction
btw, 2-factor authentication is enabled with my Google account, so I followed this instruction to get my "app password"
But after I start my Admin Server application, and wait 20 second, the error appears
I have tried change port to 465, not working
I have tried spring.mail.properties.mail.smtp.socketFactory.port and configure it to 465, not working
I'm using Windows 11 and windows firewall has no Outbound rule against java, java platform, intelliJ idea, there're Inbound rules that block java and java(TM) platform, not working
With my config above, Admin Server should send a mail to xxx#outlook.com from xxx#gmail.com.
In application.yml, I need to config https port and http port.
For this, code is as follows in application.properties.
server.port.http=80
server.port.https=443
In application.yml, I tried follwing code for configuration,
but it doesn't work.
code1
server:
port: 443
http: 80
code2
server:
port:
http: 80
port: 443
How do this only with application.yml?
I can do it with collaboration of .properties and .yml.
However, I want to do this with only application.yml.
Solution
I found solution thanks to answer of dariosicily.
I configured https and http port as follows.
server:
port: 443
ports:
https: 443
http: 8080
I need to configure default port of spring boot.
So, I configured default port using server.port=443,
and https and http port using server.ports.
And used them in java as follows.
#Value("${server.ports.http}")
private int serverPortHttp;
#Value("${server.ports.https}")
private int serverPortHttps;
It works really well. Thank you!!!
You can configure both http and https ports creating a dictionary with http and https keys in your application.yml :
server:
port:
http: 8080
https: 443
Then you can access both properties in your java class (or kotlin with an equivalent code) :
#Value("${server.port.http}")
private int httpPort;
#Value("${server.port.https}")
private int httpsPort;
Is it still possible to change the actuator port in 2.3.4?
neither management.port nor management.endpoints.port seems to work. Intellij doesn't recognize any of these settings, either.
It is management.server.port. Customizing the Management Server Port
With these settings:
server:
port: 8082
management:
server:
port: 8081
the default app port is 8082 and the actuator data is exposed at 8081
I have configured the below health check properties in my spring boot application(using actuator) and returning "UP" when locally tested using the below endpoint
server:
servlet:
context-path: /account/v1
port: 8443
management:
endpoints:
web:
path-mapping:
health: /health
Check locally using "http://localhost:8443/account/v1/actuator/health and returning
{"status":"UP"}"
In PCF I updated the Health check type as "http" and Endpoint as "/actuator/health".
When I pushed my app I am getting the below error
2020-09-02T12:43:15.92+0530 [HEALTH/0] ERR Failed to make HTTP request to '/actuator/health' on port 8080: connection refused
2020-09-02T12:43:15.92+0530 [CELL/0] ERR Failed after 1m0.632s: readiness health check never passed.
Please help on this.(Is my port or endpoint wrong)
I am trying to send email using spring-boot-starter-mail and the result is
Failed message 1: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.gmail.com, 587; timeout 5000;
My application.properties are
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=<email>
spring.mail.password=<password>
# Other properties
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
# TLS , port 587
spring.mail.properties.mail.smtp.ssl.trust=smtp.gmail.com
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.starttls.enable=true
I have tried myriad combinations and all roads lead to this same exception! I can telnet to smtp.gmail.com 587 and receive a response
220 smtp.gmail.com ESMTP e82sm2105370oia.36 - gsmtp
Many links I followed suggested a firewall might be to blame. Has anyone seen this issue?
Are you using a proxy? If your telnet is successful then it’s using some configuration that your spring application lacks, perhaps an environment variable such as HTTP_PROXY is set? The most likely scenario I come across in this situation is this issue. You would them need to set this as normal for any java application by passing the
-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128
arguments.