Android does not trigger eventListeners
This package works flawlessly on iOS
But on Android no event listeners have been triggered
", "CRLF": "LOSED": 2, "CONNECTING": 0, "CR": " ", "ERROR": -1, "LF": " ", "OPEN": 1, "_lastIndexProcessed": 0, "_pollTimer": 205, "_xhr": null, "body": undefined, "debug": false, "eventHandlers": {"close": [], "error": [], "message": [], "open": []}, "headers": {}, "interval": 5000, "lastEventId": null, "lineEndingCharacter": null, "method": "GET", "status": 0, "timeout": 0, "timeoutBeforeConnection": 500, "url": "https://.../events/4213f51b-dec8-4f8c-a36e-7ad5fe8cd725_limit/984", "withCredentials": false}
if (!streamingChannel?.channel_name || !streamingChannel.query_id) return;
resetValues();
const es = new EventSource<Bindings>(
`${process.env.EXPO_PUBLIC_API_URL}/events/${streamingChannel.channel_name}/${streamingChannel.query_id}`,
);
console.log('es', es);
setIsStreaming(true);
es.addEventListener('start', (i) => {
console.log('start', i);
});
es.addEventListener('error', (i) => {
console.log('error', i);
});
es.addEventListener('message', (i) => {
console.log('message', i);
});
// ----------------- Event Listeners -----------------
es.addEventListener('answer', answerHandler);
es.addEventListener('context', contextHandler);
es.addEventListener('references', referencesHandler);
es.addEventListener('end', () => {
setIsStreaming(false);
es.removeAllEventListeners();
});
// Call the ready to listen.
// note - this function, must be called after the channel is connected.
// only call when you are ready to receive events
readyToListen(streamingChannel).catch((error) => {
console.error(error);
setIsStreaming(false);
});
return () => {
es.close();
};
This is happening on Expo "expo": "^50.0.13", "axios": "^1.6.7", "react-native-sse": "^1.2.1",
Please check out the existing issues before you open a new one. This problem has been raised and answered about a dozen times now.
Just have a look at this:
https://stackoverflow.com/questions/69235694/react-native-cant-connect-to-sse-in-android/69235695#answer-69235695
Here is a recent comment that summarizes the situation:
https://github.com/binaryminds/react-native-sse/issues/26#issuecomment-2002032183
And since you're using Expo, this comment might be relevant for you:
https://github.com/facebook/react-native/issues/28835#issuecomment-1986196675