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

Android does not trigger eventListeners #49

Closed
asapMaki opened this issue Mar 22, 2024 · 1 comment
Closed

Android does not trigger eventListeners #49

asapMaki opened this issue Mar 22, 2024 · 1 comment

Comments

@asapMaki
Copy link

This package works flawlessly on iOS
But on Android no event listeners have been triggered
", "CRLF": "LOSED": 2, "CONNECTING": 0, "CR": " ", "ERROR": -1, "LF": " ", "OPEN": 1, "_lastIndexProcessed": 0, "_pollTimer": 205, "_xhr": null, "body": undefined, "debug": false, "eventHandlers": {"close": [], "error": [], "message": [], "open": []}, "headers": {}, "interval": 5000, "lastEventId": null, "lineEndingCharacter": null, "method": "GET", "status": 0, "timeout": 0, "timeoutBeforeConnection": 500, "url": "https://.../events/4213f51b-dec8-4f8c-a36e-7ad5fe8cd725_limit/984", "withCredentials": false}

        if (!streamingChannel?.channel_name || !streamingChannel.query_id) return;
        resetValues();
        const es = new EventSource<Bindings>(
            `${process.env.EXPO_PUBLIC_API_URL}/events/${streamingChannel.channel_name}/${streamingChannel.query_id}`,
        );
        console.log('es', es);
        setIsStreaming(true);

        es.addEventListener('start', (i) => {
            console.log('start', i);
        });
        es.addEventListener('error', (i) => {
            console.log('error', i);
        });
        es.addEventListener('message', (i) => {
            console.log('message', i);
        });
        // ----------------- Event Listeners -----------------
        es.addEventListener('answer', answerHandler);
        es.addEventListener('context', contextHandler);
        es.addEventListener('references', referencesHandler);
        es.addEventListener('end', () => {
            setIsStreaming(false);
            es.removeAllEventListeners();
        });
        // Call the ready to listen.
        // note - this function, must be called after the channel is connected.
        // only call when you are ready to receive events
        readyToListen(streamingChannel).catch((error) => {
            console.error(error);
            setIsStreaming(false);
        });

        return () => {
            es.close();
        };

This is happening on Expo
"expo": "^50.0.13",
"axios": "^1.6.7",
"react-native-sse": "^1.2.1",

@EmilJunker
Copy link
Contributor

Please check out the existing issues before you open a new one. This problem has been raised and answered about a dozen times now.

Just have a look at this:

https://stackoverflow.com/questions/69235694/react-native-cant-connect-to-sse-in-android/69235695#answer-69235695

Here is a recent comment that summarizes the situation:

#26 (comment)

And since you're using Expo, this comment might be relevant for you:

facebook/react-native#28835 (comment)

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

3 participants