Skip to content
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

EventSource is not working in android #1

Closed
tmirun opened this issue Dec 12, 2020 · 9 comments
Closed

EventSource is not working in android #1

tmirun opened this issue Dec 12, 2020 · 9 comments

Comments

@tmirun
Copy link

tmirun commented Dec 12, 2020

hi @NepeinAV,
I am testing the library rc-eventsource-reborn.

it is not working in android device. including comment these lines.

did it work for you?

// try to comment this code
      ________________________
      NetworkingModule.setCustomClientBuilder(
        new NetworkingModule.CustomClientBuilder() {
          @Override
          public void apply(OkHttpClient.Builder builder) {
            builder.addNetworkInterceptor(new     FlipperOkhttpInterceptor(networkFlipperPlugin));
          }
        }
      );
      _______________________
@NepeinAV
Copy link
Owner

NepeinAV commented Dec 12, 2020

Hey!

  1. Is it working on iOS device or emulator?
  2. Did you try to run your app in Release mode?
  3. Did you try to handle errors? What type of errors did you see in console? What basically happens when you try to use EventSource?
  4. Provide minimal example of how you are using this (including package.json)

@tmirun
Copy link
Author

tmirun commented Dec 12, 2020

in ios and ios simulator works perfectly. the problem is in android, I was testing with debug mode (run yarn android in react-native 0.63), it's not working in real device and emulator

basically the problem is onmessage doesn't call. (in ios work 👍)

I am looking for why happen this problem, I found this issue in react native, I think event source polyfill doesn't work in android. and maybe the problem is related to the Networking module
facebook/react-native#28835

@NepeinAV
Copy link
Owner

I'm just tried to create new RN app and it is working fine.

Try it by yourself - https://github.com/NepeinAV/SSETest.

@NepeinAV
Copy link
Owner

Initially SSE wasn't working, but after i comment that lines of code it starts successfully.

@tmirun
Copy link
Author

tmirun commented Dec 12, 2020

thank you a lot for responding quickly.
I will try it now and tell you some thing

@tmirun
Copy link
Author

tmirun commented Dec 12, 2020

very strange it working for your project.

So the problem will be with openhab sse channel 🤔

when I try to connect return this error

error Event {isTrusted: false}

ok, I will invest in this problem.

can you explain why we need to comment these lines? (I am not native programmer)

// try to comment this code
      ________________________
      NetworkingModule.setCustomClientBuilder(
        new NetworkingModule.CustomClientBuilder() {
          @Override
          public void apply(OkHttpClient.Builder builder) {
            builder.addNetworkInterceptor(new     FlipperOkhttpInterceptor(networkFlipperPlugin));
          }
        }
      );
      _______________________

Thank you

@NepeinAV
Copy link
Owner

So this is network interceptor that allows us to see network interaction in Flipper app. My app was working in release mode, but not in debug and only one difference between them was this interceptor.

This is not a right solution to solve this problem, but at least my app is working as needed right now.

@tmirun
Copy link
Author

tmirun commented Dec 12, 2020

kk, I think this problem is something that should resolve by react-native team.

I am following this issue, facebook/react-native#28835, hope RN team can do something to make SSE work in pure JS without a thirty party library.

also, I mentioned 'rn-eventsource-reborn' in it. 😂

Thank you a lot. hope the ppl use this library and make it popular 😉

@tmirun
Copy link
Author

tmirun commented Dec 12, 2020

I will close this Issue

@tmirun tmirun closed this as completed Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants