Socket.Io-Client is not working on Android
See original GitHub issue@darrachequesne not working on Android… I have updated engine.io-client to 4.0.4. react-native : 0.63.4 socket.io-client:3.0.3 socket.io: 3.0.3
I have created a Hook. It’s working Good in IOS.
`import {useEffect, useRef} from ‘react’; import io from ‘socket.io-client’; import {getUniqueId} from ‘react-native-device-info’; import { MessageReq } from ‘…/Types/chat’;
const useSocket = () => { const ref = useRef<SocketIOClient.Socket>(); const sendChat = (req: MessageReq) => { ref.current!.emit(‘sendMessage’, req); };
const setUpRoom = (userGuid: string | null) => { const deviceId = getUniqueId(); const userGuid=‘xyz’; console.log(ref.current!.emit(‘online’, {deviceId, userGuid})); ref.current!.emit(‘online’, {deviceId, userGuid}); }; useEffect(() => { console.log(‘here’); const socket = io(‘http://localhost:3000’, {reconnection:true,}); ref.current = socket; }, []); return { sendChat, setUpRoom, }; }; export default useSocket;`
Log:
_Originally posted by @AGurindapalli in https://github.com/socketio/socket.io-client/issues/1411#issuecomment-737726037_
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:26 (3 by maintainers)
Top GitHub Comments
I got solution with just downgrade the version. I install npm install socket.io-client@2.3.0 I mean 2.3.0 version and successfully connect
Thanks. It worked for me too. Following are the working versions socket.io-client@2.3.0 engine.io-client@3.4.4 ( installs along with socket.io-client) react-native@0.63.3