Skip to content

Event-Source onMessage is not triggering for both android and iOS platform. #70

@amit13091992

Description

@amit13091992

I have a project in react native CLI.

  "react": "^18.2.0",
  "react-native": "^0.73.9",
  "react-native-sse": "^1.2.1"

Usage:

   const createVitalsEventSource = async () => {
       const url = `EVENT_SOURCE_WEB_SOCKET_URL`;

       const eventSource = new EventSource(url, {
           headers: {
               Authorization: `Bearer ${token}`,
           },
           withCredentials: true,
           lineEndingCharacter: '\n',
           debug: true,
           pollingInterval: 0,
           timeoutBeforeConnection: 1000,
       });
       eventSourceRef.current = eventSource;

       const listener: EventSourceListener = (event: any) => {
           if (event.type === "open") {
               console.log('openSSEConnection');
           } else if (event.type === "message") {
               console.log('getting event message');
           } else if (event.type === "error") {
               console.log('getting event error');
           } else if (event.type === "close") {
               console.log('closing event source');
           }
       };
       eventSource.addEventListener("open", listener);
       eventSource.addEventListener("message", listener);
       eventSource.addEventListener("error", listener);
       eventSource.addEventListener("close", listener);
   };

It was working around a week back but suddenly stopped working.
Note: In Android, it is not at all working so I needed to use another library "react-native-oksse"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions