-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
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
Labels
No labels