-
Notifications
You must be signed in to change notification settings - Fork 41
cant connect to server sent events #34
Comments
which platform are you running this on? i was able to get this library working on iOS, but not android it seems like the xhr |
Yep this does not work on Android unless the connection is closed on the server side. one approach with which this can be made to work is after we have sent the data that we want from the server we close the connection. But for that to happen correctly there needs to be some state management on the server side. Or, if you can risk using native modules non-javascript based then there are plenty. I'm using: https://github.com/ExpandoPakistan/react-native-eventsource. But there's a catch! these are not a pure Javascript implementations and may break if the repositories go un maintained. |
Try to disable Flipper network interceptor. Go to android/app/src/debug/java//ReactNativeFlipper.java and comment next lines of code:
|
if i console data from server , it doesnt work , please help my code is as below
const getMessages = () => {
console.log('ken')
const eventSource = new RNEventSource('https://328f2c2d8b21.ngrok.io/sse2');
eventSource.addEventListener("message", (data) => {
console.log(data.data);
});
}
getMessages();
The text was updated successfully, but these errors were encountered: