You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Event-Source onMessage is not triggering for both android and iOS platform. #70
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"
changed the title [-]Event-Source onMessage is not working for both android and iOS platform.[/-][+]Event-Source onMessage is not triggering for both android and iOS platform.[/+]on Nov 19, 2024
@EmilJunker
Please find below logs that I receive when I start connecting using Event source:
DEBUG [EventSource] Will open new connection in 1000 ms.
DEBUG [EventSource][onreadystatechange] ReadyState: HEADERS_RECEIVED(2), status: 200
DEBUG [EventSource][onreadystatechange] ReadyState: LOADING(3), status: 200
LOG Open SSE connection.
DEBUG [EventSource][onreadystatechange][OPEN] Connection opened.
DEBUG [EventSource][onreadystatechange] ReadyState: LOADING(3), status: 200
DEBUG [EventSource][onreadystatechange] ReadyState: LOADING(3), status: 200
DEBUG [EventSource][onreadystatechange] ReadyState: LOADING(3), status: 200
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.
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.
t 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 :(
I don't know yet why it's not working with your other backend, though. I think it might be related to the lineEndingCharacter option that you specify. Have you tried it without that option?
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:
@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. Logic:
@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!
Activity
[-]Event-Source onMessage is not working for both android and iOS platform.[/-][+]Event-Source onMessage is not triggering for both android and iOS platform.[/+]EmilJunker commentedon Nov 19, 2024
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.
amit13091992 commentedon Nov 19, 2024
Okay but should work in iOS thought right ?
EmilJunker commentedon Nov 19, 2024
Yes, but we can only help you if you show us the logs.
amit13091992 commentedon Nov 20, 2024
@EmilJunker
Please find below logs that I receive when I start connecting using Event source:
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.
EmilJunker commentedon Nov 20, 2024
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.
amit13091992 commentedon Nov 20, 2024
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 :(
EmilJunker commentedon Nov 20, 2024
Does your app work if you connect to this SSE test endpoint instead of the actual backend?
https://fetch-eventstream.glitch.me/sse
amit13091992 commentedon Nov 20, 2024
LOGS:
LOG calling event source {"type":"open"}
LOG Open SSE connection.
After this, nothing comes in logs. @EmilJunker
EmilJunker commentedon Nov 20, 2024
Sorry, I forgot to tell you to add an event listener for the "increment" event like so:
amit13091992 commentedon Nov 20, 2024
Updated Library code like below:
EmilJunker commentedon Nov 20, 2024
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
lineEndingCharacteroption that you specify. Have you tried it without that option?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:
amit13091992 commentedon Nov 20, 2024
@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.
Logic:
LOGS:
amit13091992 commentedon Nov 20, 2024
tried this but didn't help. @EmilJunker
EmilJunker commentedon Nov 20, 2024
@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!