socket.io not firing on production mode when live reload page. but firing on dev mode

import { socket } from "../../socket";
  useEffect(() => {
   socket.emit("sedo-domain-list");

    socket.on("sedo-domain-list", (domain) => {
      setData(domain);
      console.log(domain);
      socket.off("sedo-domain-list");
    });

    return () => {
      socket.off("sedo-domain-list");
    };
  }, []);

This is my code. This code working fine in dev mode but when I build the nextjs project, its not firing on first page reload or live reload. but firing on when I change the routes and returned to the page.

And this is my socket.js file

import io from "socket.io-client";
export const socket = io("http://localhost:5000");

And this is my server file

socket.on("sedo-domain-list", () => {
    console.log("logging", socket.id)
}

Please help