Unable to read DHT record from other peers

I am building a peer to peer network where I store some information on the DHT.
I am encountering an issue where after I save data on one peer, the data can’t be GET from the other peer.

Here are my two nodes files(the first is the master node and the second is the dialer node) :

import { createLibp2p } from 'libp2p';
import { tcp } from '@libp2p/tcp';
import { noise } from '@chainsafe/libp2p-noise';
import { stdinToStream, streamToConsole } from './stream.js';
import { yamux } from '@chainsafe/libp2p-yamux';
import { pipe } from 'it-pipe';
import { kadDHT } from '@libp2p/kad-dht';
import { identify, identifyPush } from '@libp2p/identify';
import { fromString as uint8fromString } from 'uint8arrays/from-string';
import { toString as uint8toString } from 'uint8arrays';
import { peerIdFromString } from '@libp2p/peer-id';
import last from 'it-last';
const start_server = async () => {
    const node = await createLibp2p({
        addresses: {
            listen: ["/ip4/0.0.0.0/tcp/10334"]
        },
        transports: [
            tcp()
        ],
        streamMuxers: [
            yamux()
        ],
        connectionEncrypters: [
            noise()
        ],
        services: {
            identify: identify(),
            lanDHT: kadDHT({
                protocol: '/ipfs/lan/kad/1.0.0'
            })
            // dht : new kadDHT()
        }
    });

    

    const peerId = node.peerId;
    console.log('Peer ID:', peerId.toCID());

    node.services.lanDHT.setMode("server");
   
    node.addEventListener('peer:connect', (evt) => {
        console.log("New peer connected", evt);
    })

    await node.handle('/chat/1.0.0', async ({ stream }) => {
        console.log("New stream of chat protocol just to record some data on new stream from dialer");

        console.log("Saving value to DHT");
        
        const has_put = await node.services.lanDHT.put(uint8fromString('hi'), uint8fromString('world'));
        for await (const evt of has_put) {
        }

        setInterval(async () => {
            console.log("Trying to read DHT");
            const res = node.services.lanDHT.get(uint8fromString('hi'));

            for await (const evt of res) {
                if (evt.name === 'VALUE') {
                    console.log('VALUE 1', uint8toString(evt.value)); // THIS WORKS
                    break;
                }
            }

           
        }, 5000);

        await pipe(
            stream.source,
            async function (source) {
                // console.log(source);
                for await (const msg of source) {
                    console.log('Received:', msg.toString());
                }
            }
        );
    });

    node.getMultiaddrs().forEach((ma) => {
        console.log('Listening on:', ma.toString());
    });

    console.log('Node started!');
}

start_server();

Here is the dialer source code :

import { noise } from "@chainsafe/libp2p-noise";
import { bootstrap } from "@libp2p/bootstrap";
import { mdns } from "@libp2p/mdns";
import { tcp } from "@libp2p/tcp"
import { createLibp2p } from "libp2p"
import { stdin } from "process";
import { stdinToStream, streamToConsole } from "./stream.js";
import { yamux } from "@chainsafe/libp2p-yamux";
import { pipe } from "it-pipe";
import { pushable } from "it-pushable";
import { identify } from "@libp2p/identify";
import { kadDHT } from "@libp2p/kad-dht";
import { fromString as uint8fromString } from 'uint8arrays/from-string';
import { toString as uint8toString } from 'uint8arrays';
import last from "it-last";
import { peerIdFromString } from "@libp2p/peer-id";

const start_dialing = async () => {
    const dialer = await createLibp2p({
        addresses: {
            listen: ["/ip4/0.0.0.0/tcp/0"]
        },
        transports: [
            tcp()
        ],
        streamMuxers: [
            yamux()
        ],
        connectionEncrypters: [
            noise()
        ],
        peerDiscovery: [
            bootstrap({
                interval: 60e3,
                list: [
                    '/ip4/127.0.0.1/tcp/10334/p2p/12D3KooWBfdXnKNzBhMcikQyzAus5UHYFXzGaFoNDkah2CyKemYX' //This ID was passing on my device
                ]
            }),
            mdns()
        ],
        services: {
            identify: identify(),
            lanDHT: kadDHT({
                protocol: '/ipfs/lan/kad/1.0.0'
            })
        }
    });

    dialer.services.lanDHT.setMode("client");

    console.log('Dialer ready, listening on : ');
    dialer.getMultiaddrs().forEach((ma) => {
        console.log(ma.toString());
    });

    dialer.addEventListener('peer:discovery', async (evt) => {
        console.info("peer:discovery", evt.detail);
        console.log(evt);
        await dialer.dial(evt.detail.id);

        const dht_peer_id = peerIdFromString("12D3KooWAD46ZuhFJaaoYAhQ9QSsG4vKsZEcNhSoVePnuFiZxDwD"); //I CAN FIND THIS PEER but Idk how to use this connection, I did not find documentation about it.
        const peer_info = await dialer.peerRouting.findPeer(dht_peer_id);
        const close_peers = await dialer.peerRouting.getClosestPeers();
        console.info("Peer info", peer_info);
        
        const peer = await dialer.peerRouting.findPeer(dht_peer_id);

        dialer.dialProtocol(evt.detail.multiaddrs, '/chat/1.0.0')
            .then(async (stream) => {
                stdinToStream(stream);
                streamToConsole(stream);

                
                console.log("Delaying for 5 seconds for DHT to be ready");
                await new Promise((resolve) => setTimeout(resolve, 5000));

                setInterval(async () => {
                    console.log("Trying to read DHT");
                    const saving = await dialer.services.lanDHT.put(uint8fromString('huk'), uint8fromString('wild'));
                    for await (const evt of saving) {
                        console.log("Saving value to DHT", evt);
                    }
                    let res = dialer.services.lanDHT.get(uint8fromString('huk'));
                    let res_2 = dialer.services.lanDHT.get(uint8fromString('hi'));

                    for await (const evt of res) {
                        if (evt.name === 'VALUE') {
                            console.log('Value Dialer : ', uint8toString(evt.value));
                        }
                    }

                    for await (const evt of res_2) {
                        if (evt.name === 'VALUE') {
                            console.log('Value Node : ', uint8toString(evt.value));
                        }
                    }
                    console.log("\n\n");
                    
                }, 3000);

            })
            .catch((err) => {
                console.error('error dialing to peer:', evt.detail, err);
            });
    });

    dialer.start();
    console.log('Dialer started!');
}

start_dialing();

HERE ARE MY QUESTIONS

  1. What’s wrong here? Any help is really appreciated.
  2. Another question, can I have DHT records on all types of Nodes or does it work only on server nodes? What about in browser execution?