Comments (16)
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.
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.
@Aung-Myint-Thein so how did you do it. Please share code snippets or example.
from react-native-socket-io-example.
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.
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.
@Arpitrf Can you elaborate more?
from react-native-socket-io-example.
@rhuantac works for me,
from react-native-socket-io-example.
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.
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.
Hey, Any luck anyone ?
from react-native-socket-io-example.
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.
Did anyone resolved the issue for android?
from react-native-socket-io-example.
bump
from react-native-socket-io-example.
@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.
Still not working for Android. can someone suggest something which can work on both platform?
from react-native-socket-io-example.
Did anyone find the android fix not able to connect to server from client
from react-native-socket-io-example.
Related Issues (18)
- Throws an error HOT 4
- It take a long time to build with x code
- |this| is not a function inside Function.prototype.bind HOT 1
- Can't run server with npm run server HOT 1
- Not receiving message from terminal to android device, on ios working fine HOT 1
- MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017] HOT 3
- Production ready ?
- This error show when i press enter in console HOT 2
- Can i create socketServer with react native? Anyone help me?
- app crashed HOT 1
- Error: Document is not defined on ReactNative HOT 1
- Running as a mobile app on a device. HOT 3
- Unknown named module:'xmlhttprequest-ssl' HOT 2
- How to emit json object in android HOT 1
- How to use socket-io in android ? HOT 1
- How to upload file on Node Server HOT 1
- How to handle Socket Connect Fail Error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-socket-io-example.