-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event-Source onMessage is not triggering for both android and iOS platform. #70
Comments
To get SSE working on Android with React Native versions prior to 0.74, you have to disable the Flipper plugin. 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. If you run into more issues, please share the logs with us so we can see what is going on. |
Okay but should work in iOS thought right ? |
Yes, but we can only help you if you show us the logs. |
@EmilJunker
After waiting for 5 to 10 minutes, it remains the same. I have already attached a code reference. If any other additional information is needed please let me know. |
If everything was working correctly, there should be a lot more log messages of the kind
Are you sure that the SSE endpoint you connect to is working properly? I find it suspicious that a week ago everything was working fine and it suddenly stopped. This sounds like a backend issue to me. |
I have checked from backend side, after confirming i.e. nothing changed from backend, I checked on the app side. @EmilJunker Could you please help me out on this issue, as suddenly It stopped working, it has become a blocker :( |
Does your app work if you connect to this SSE test endpoint instead of the actual backend? |
LOGS: After this, nothing comes in logs. @EmilJunker |
Sorry, I forgot to tell you to add an event listener for the "increment" event like so:
|
Updated Library code like below:
|
Good, so the example from glitch.me works. I don't know yet why it's not working with your other backend, though. I think it might be related to the By the way, you don't need to edit the library code to add custom events (like "increment"). You can do that with a type parameter like so: type CustomEvents = 'increment' | 'decrement';
const eventSource = new EventSource<CustomEvents>(url, {});
const listener: EventSourceListener<CustomEvents> = (event) => {
...
};
eventSource.addEventListener('increment', listener); |
@EmilJunker with my implementation, I am attaching token as well in the header i.e. the change which I have in my implementation. I have added latest change you suggested for the increment one. But still the issue persists.
LOGS:
|
tried this but didn't help. @EmilJunker |
@amit13091992 Sorry, I'm out of ideas. I don't see anything wrong with your code. I still think it must be a backend issue. I'm afraid you're on your own - good luck! |
I have a project in react native CLI.
Usage:
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"
The text was updated successfully, but these errors were encountered: