I need help to configure Mosquitto mqtt in linux vm for Persistence

listener 1883
listener 9001
protocol websockets
socket_domain ipv4
#certfile /etc/nginx/certificate/smarti-vm.crt
#keyfile /etc/nginx/certificate/smarti-vm.key
max_packet_size 1000000
password_file /etc/mosquitto/passwd
allow_anonymous false

persistence true
persistence_location /etc/mosquitto/
persistence_file mosquitto.db
After reloading i have publish and subscribe code in c# which I ran to check if persistence works but it didnt. I purposely disconnected my client and again ran the program but I didnt recieve the messages that was not acknowleddged by the client.

Hello,

Can you describe your test a little closer, please?
Persistence turned on means the broker will store retained messages and subscription state across restarts. What exactly do you mean by messages not arriving?

If you want to prevent messages from being lost if a client subscriber disconnects and reconnects, you have to use Persistent Sessions. This is done via the client connection.
Only then will a broker remember your client and wait for his arrival again. You must combine this with QoS>0 and a static clientID for the client connection.

Cheers,

Tizian