binaryminds / react-native-sse

Event Source implementation for React Native. Server-Sent Events (SSE) for iOS and Android 🚀
https://www.npmjs.com/package/react-native-sse
MIT License
196 stars 30 forks source link

SSE doesn't work on ANDROID RN 0.74 withouth Flipper #61

Open taniibarra opened 2 months ago

taniibarra commented 2 months ago

My application does not receive events in android but it does in ios. We don't have the Flipper java plugign and still in DEBUG mode it is only in [EventSource] Will open new connection in 500 ms. After that nothing else arrives. In IOS it works correctly and events continue to arrive.

EmilJunker commented 2 months ago

I'm using this library on React Native 0.74 without issues. There must be some problem with your code.

Have you checked if the problem also occurs in RELEASE mode?

NurRachman commented 1 month ago

i'm getting the same problem in "react-native": "0.71.8" and "react-native-sse": "^1.1.0". I have tried using version 1.2.1 but it still doesn't work.

i tried creating a new project "react-native": "0.74.3" and used "react-native-sse": "^1.2.1" for this one worked fine. are there any changes that need to be adjusted for previous versions of react native?

EmilJunker commented 1 month ago

@NurRachman In version 0.74 of react-native, the Flipper plugin was removed. That's why react-native-sse is now working right out of the box.

In older versions of react-native, you need to manually disable Flipper. As long as Flipper is enabled, SSE won't work in debug builds.

NurRachman commented 1 month ago

@EmilJunker I've tried it, and it works. Thanks.

amit13091992 commented 1 month ago

any updates on this? Need a fix for this issue. Here are my package version information

"react": "18.2.0",
"react-native": "^0.73.6",
"react-native-sse": "^1.2.1",
EmilJunker commented 1 month ago

@amit13091992 You need to disable Flipper, see https://stackoverflow.com/questions/69235694/react-native-cant-connect-to-sse-in-android/69235695#answer-69235695

As long as Flipper is enabled, SSE won't work in debug builds on Android.

amit13091992 commented 1 month ago

@amit13091992 You need to disable Flipper, see https://stackoverflow.com/questions/69235694/react-native-cant-connect-to-sse-in-android/69235695#answer-69235695

As long as Flipper is enabled, SSE won't work in debug builds on Android.

@EmilJunker this file is not available in my project, as I am using the new version of react-native.

EmilJunker commented 1 month ago

this file is not available in my project, as I am using the new version of react-native.

Just search your project for the word "Flipper". I assure you that you will find it somewhere.

wojciechkrol commented 1 month ago

Hello everyone,

I checked the case yesterday and in the latest version of React Native (0.74.3), the issue does not occur. I also checked version React Native (0.73.6) and I have to confirm that the problem occurs. In Expo 51, event-stream is blocked by the dev tools interceptor. Theoretically, the problem has been resolved, but for some reason, events are not dispatched until the stream ends.

Ref: https://github.com/expo/expo/issues/27526

EmilJunker commented 1 month ago

In Expo 51, event-stream is blocked by the dev tools interceptor.

There is supposedly a fix for the Expo dev tools interceptor, available here: https://github.com/MartinHarkins/expo-sse-patch Did you try it?

Off2Race commented 5 days ago

Hi, @EmilJunker – Have you guys considered adding a note to the README telling people to disable Flipper for RN < 0.74, specifically for Android in debug? I ran into this problem myself and fortunately found this thread relatively quickly. Others might not be so lucky if they're working purely from the install instructions in the README. Just a suggestion :)