GithubHelp home page GithubHelp logo

Comments (16)

Aung-Myint-Thein avatar Aung-Myint-Thein commented on June 19, 2024 2

I managed to work for Android too. For android, we cannot use 127.0.0.1 or localhost. Need to specify the server machine's IP address. Thanks! :D sorry for wrong flag!

from react-native-socket-io-example.

rhuantac avatar rhuantac commented on June 19, 2024 1

If anyone having this issue yet, I've found a simple fix here: https://stackoverflow.com/a/41400394

Just change line 3 of client\index.js to:

import SocketIOClient from 'socket.io-client/dist/socket.io.js';

from react-native-socket-io-example.

ronastlelobo avatar ronastlelobo commented on June 19, 2024 1

@Aung-Myint-Thein so how did you do it. Please share code snippets or example.

from react-native-socket-io-example.

Sathyanarayan09 avatar Sathyanarayan09 commented on June 19, 2024

Its not working on Android and Im getting an error as -- Unknown named module: 'xmlhttprequest-ssl' --
can you please help me to fix this issue?

from react-native-socket-io-example.

Arpitrf avatar Arpitrf commented on June 19, 2024

The same problem. Not working in android, but working in ios.
Also tried @rhuantac solution. Still dosen't work.

from react-native-socket-io-example.

vinnyoodles avatar vinnyoodles commented on June 19, 2024

@Arpitrf Can you elaborate more?

from react-native-socket-io-example.

xliank avatar xliank commented on June 19, 2024

@rhuantac works for me,

from react-native-socket-io-example.

Aung-Myint-Thein avatar Aung-Myint-Thein commented on June 19, 2024

I just tried the repo. It is working fine on iOS but on Android, I am not receiving anything. I cannot debug remotely too.

I tried adding these lines in the constructor but nothing come out too.

this.socket.on('disconnect', () => {
      alert('disconnected');
    });

    this.socket.on('connect', () => {
      alert('connected');
    })

Can you please try the repo on Android and see if it is working? or do you have any idea where it could be wrong in our settings? Thanks!

from react-native-socket-io-example.

sharathkoppolu avatar sharathkoppolu commented on June 19, 2024

This example is working fine but when I tried to use the client code in another project I am receiving this warning:
Received data was not a string, or was not a recognized encoding.

React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
Memory: 1.56 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.9.1 - /usr/local/bin/node
npm: 5.5.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
IDEs:
Android Studio: 3.0 AI-171.4408382
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react: 16.4.1 => 16.4.1
react-native: 0.56.0 => 0.56.0
npmGlobalPackages:
react-native-cli: 2.0.1

Package.json file:
{
"name": "xyz",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"react": "16.4.1",
"react-native": "0.56.0",
"react-native-gifted-chat": "^0.4.3",
"react-native-image-picker": "^0.26.10",
"react-navigation": "^2.9.3",
"socket.io": "^2.1.1",
"underscore": "^1.9.1"
},
"devDependencies": {
"babel-jest": "23.4.2",
"babel-preset-react-native": "5.0.2",
"jest": "23.4.2",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native"
}
}

I am not able to debug the code also. please help me.

from react-native-socket-io-example.

ronastlelobo avatar ronastlelobo commented on June 19, 2024

Hey, Any luck anyone ?

from react-native-socket-io-example.

lorenzgrossi avatar lorenzgrossi commented on June 19, 2024

Hi, this example still not work on Android phone!

I tried on 2 physical devices:

  • Nexus 5 (Android 6.0.1)
  • Nexus 5X (Android 8.0.1)

This is what I got in my package.json:
{
"name": "react-native-socket-io-example",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"ios": "react-native run-ios",
"android": "react-native run-android",
"server": "nodemon server"
},
"dependencies": {
"express": "^4.14.0",
"mongojs": "^2.4.0",
"nodemon": "^1.11.0",
"react": "15.4.1",
"react-native": "0.39.2",
"react-native-cli": "^2.0.1",
"react-native-gifted-chat": "0.0.10",
"socket.io": "^1.7.2"
},
"devDependencies": {
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "18.0.0",
"react-test-renderer": "15.4.1"
},
"jest": {
"preset": "react-native"
}
}

When I run the npm run android command the application starts correctly on the device, but when I try to send message I receive this error:
com.reactnativesocketioexample E/ReactNativeJS: In this environment the sources for assign MUST be an object.This error is a performance optimization and not spec compliant.

I added a listener on the 'connect_error' event in client/index.js file :
this.socket.on('connect_error', (err) => { console.log('socket connected error --> ' + err); })

after some minutes since the start of the application I see the log:
socket connected error --> timeout

Any suggestions ?

Thanks

from react-native-socket-io-example.

PriyaJainDev avatar PriyaJainDev commented on June 19, 2024

Did anyone resolved the issue for android?

from react-native-socket-io-example.

filipef101 avatar filipef101 commented on June 19, 2024

bump

from react-native-socket-io-example.

stanrud avatar stanrud commented on June 19, 2024

@priya0607jain @ronastlelobo @filipef101
The easy and fast solution is:
Put your local IP address instead of 127.0.0.1 or localhost.

If you don't know how to check your IP
Run the command in the terminal to find out:
Use ipconfig getifaddr en1 for wireless, or ipconfig getifaddr en0 for ethernet.

from react-native-socket-io-example.

ThakkarKhushbu avatar ThakkarKhushbu commented on June 19, 2024

Still not working for Android. can someone suggest something which can work on both platform?

from react-native-socket-io-example.

hrithik2322 avatar hrithik2322 commented on June 19, 2024

Did anyone find the android fix not able to connect to server from client

from react-native-socket-io-example.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.