We are using Redis 7.0.9. Our system has 1 Redis server and multiple Redis clients which are implemented in java. Redis client applications are run by the help of linux service files after login. Problem is that after rebooting client machine, linux service starts a java application and it tries to connect Redis server but throw the following exception. We didn't understand the root cause of the problem. We are not sure but it looks like client machine network is not fully initialized when application starts.

Linux service file

[Unit]
Description=Application description
After=network.target network-online.target
Wants=network.target network-online.target

[Service]
Type=simple
ExecStart=/bin/sh /opt/company/application/bin/redis-client.sh
Restart=on-failure
User=root

[Install]
WantedBy=network.target network-online.target

redis-client.sh

#!/bin/bash

export DISPLAY=:0
xhost +

java -jar /opt/company/device-setting-manager/jar/device-setting-manager-1.0.0.jar

Exception

Error in DeviceSettingActionsListener
com.company.pr.common.redislib.exceptions.YedisException: java.net.SocketException: Connection reset
    at com.company.pr.common.redislib.YedisBase.subscribeToDeviceSettingActionsChannel(YedisBase.java:345) ~[device-setting-manager-1.0.0.jar:?]
    at com.company.pr.client.devicesettingmanager.DeviceSettingManager.lambda$startDeviceSettingActionsListenerThread$0(DeviceSettingManager.java:43) ~[device-setting-manager-1.0.0.jar:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
    at java.lang.Thread.run(Thread.java:834) [?:?]