fetch-event-source icon indicating copy to clipboard operation
fetch-event-source copied to clipboard

connection close event is fired shortly after connection

Open khirod-dev opened this issue 2 years ago • 3 comments
trafficstars

Hello ,

I tried the same server side code and client side with this package and default event source . i see that server is getting close event as soon as connection is established . Just to make sure that my Server side code is not the issue I changed the client code to native event source and i cam seeing that it works as expected . i am interested to send header and other good things that this Package has . Can any one help me

My client side code (removed all other codes just to keep simple ) wrapped in useEffect reactHook

const fetchData = async () => {
      await fetchEventSource(`${serverBaseURL}`, {
        method: "POST",
        body: JSON.stringify({ userName, uniqueUserIdentifier }),
        headers: {
          Accept: "text/event-stream",
        },
        
        openWhenHidden: true,
        onclose() {
          console.log("Connection closed by the server");
        },
      });
    };
    fetchData();
  }, []);

khirod-dev avatar Jan 09 '23 00:01 khirod-dev

any update for this issue? i have the same prob

jiraiyame avatar Jun 05 '23 06:06 jiraiyame

same prob too

aurerere avatar Nov 26 '23 17:11 aurerere