question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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: Screenshot 2020-12-03 at 1 17 15 PM

_Originally posted by @AGurindapalli in https://github.com/socketio/socket.io-client/issues/1411#issuecomment-737726037_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:26 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
RahulRijhwanicommented, Dec 11, 2020

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

4reactions
soesujithcommented, Dec 14, 2020

@mabopoi I also face this issue but I got solution first uninstall old library first then try npm install socket.io-client@2.3.0

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android Node.js Socket.io not connecting - Stack Overflow
My problem is that I never see the log "one user connected" on the server but I always see the "try to connect"...
Read more >
Troubleshooting connection issues | Socket.IO
IO client will always try to reconnect, unless specifically told otherwise. Let's review how you can troubleshoot a connection failure.
Read more >
Troubleshooting connection issues | Socket.IO
You are trying to reach a plain WebSocket server · The server is not reachable · The client is not compatible with the...
Read more >
Client API - Socket.IO
This is documentation for Socket.IO 3.x, which is no longer actively maintained. For up-to-date documentation, see the latest version (4.x).
Read more >
Introduction | Socket.IO
Socket.IO is not meant to be used in a background service for mobile applications. The Socket.IO library keeps an open TCP connection to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found