WebSocket on android works slower than on ios #44292
Labels
Needs: Triage 🔍
Newer Patch Available
Platform: Android
Android applications.
Platform: iOS
iOS applications.
Description
My server code:
const WebSocket = require('ws');
// Create a WebSocket server
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', (ws) => {
console.log('Client connected');
});
React native component code:
/**
*/
import React, {useEffect} from 'react';
import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
type SectionProps = PropsWithChildren<{
title: string;
}>;
function Section({children, title}: SectionProps): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
useEffect(() => {
const ws = new WebSocket('ws://192.168.88.180:8080');
}, []);
return (
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
);
}
function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
return (
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
Edit App.tsx to change this
screen and then come back to see your edits.
Read the docs to discover what to do next:
);
}
const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
},
});
export default App;
=====================
In ios device I receive 3 messages every 1ms but in android i receive 1 message every 2ms.
Can I improve this?
It's important for me because I develop application with real time exchange.
Steps to reproduce
React Native Version
0.73.4
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/hawkf/reactNativeWebSocket.git
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: