Comments (19)
@manumaso, thanks for the feedback! Could you try two things?
- First try with
cd android
and run./gradlew clean
.- If it doesn't work try to reinstall your
node_modules
.
Worked for me! Thanks!
from react-native-tcp-socket.
@manumaso, this problem is related to the library linking because RN is not able to find the module. It is probably caused by a cache/node_module/pods bad synchronization after the automatic RN linking. I don't have experience with Expo, so I don't know the exact steps you should follow.
My advise is to reset/reinstall the library, node_modules folder, metro cache, Gradle cache and pods (and probably de PC). I hope it works, reply if the issue still persists.
Well, since it was practically a new project , what I did to fix it (after several attempts to avoid it) was to create a new project from scratch with react-native cli (since I was using Expo) and install all the dependencies again locally.
Thanks for all!
from react-native-tcp-socket.
@nthungmta207, could you provide more info about your problem (code, OS, module version)?
from react-native-tcp-socket.
@nthungmta207, please, do not share code in photo format, it could compromise your privacy and it is difficult to understand/read.
Taking a look at your initial post, I think the issue is that you are calling Sockets.connect
while you are importing 'react-native-tcp-socket'
as TcpSocket
. The correct way to call it is TcpSocket.connect
.
from react-native-tcp-socket.
import React, { Component } from 'react';
import {
View,
Text,
StyleSheet,
Dimensions,
TextInput,
KeyboardAvoidingView,
textInputOpacity,
Alert,
} from 'react-native';
import TcpSocket from 'react-native-tcp-socket';
import Svg, {Image, Circle, ClipPath} from 'react-native-svg';
import Animated, { Easing } from 'react-native-reanimated';
import { TapGestureHandler, State, TouchableOpacity } from 'react-native-gesture-handler';
function connectServer(){
var client = TcpSocket.createConnection({
port: 5555,
host: '192.168.0.108',
localAddress: "127.0.0.1",
reuseAddress: true,
// localPort: 20000,
// interface: "wifi"
}, (address) => {
this.updateChatter('opened client on ' + JSON.stringify(address));
client.write('Hello, server! Love, Client.');
});
class login extends Component {
constructor() {
super();
}
componentDidMount() {
connectServer();
}
render() {
return(
<Text>Login</Text>
)
}
}
export default login;
from react-native-tcp-socket.
@nthungmta207, if that is your code, you are calling this.updateChatter('opened client on ' + JSON.stringify(address));
when updateChatter
is undefined. Have you tested if that code throws the same error?
from react-native-tcp-socket.
I have tried but it still not working
from react-native-tcp-socket.
I have tried but it still not working
What error are you getting?
from react-native-tcp-socket.
from react-native-tcp-socket.
I am not able to reproduce the bug. It might be caused by a React Native linking error. Try to uninstall the library:
yarn remove react-native-tcp-socket
Install it again:
yarn add react-native-tcp-socket
And if you are on iOS:
cd ios && pod install
Finally, reinstall the app on the device.
from react-native-tcp-socket.
Has anyone found a solution for this error? Thanks!
from react-native-tcp-socket.
@ivantacca, could you provide your package.json and the steps you followed to install react-native-tcp-socket
?
from react-native-tcp-socket.
Hi, I have the same error but in runtime, trying to connect:
TypeError: null is not an object (evaluating 'Sockets.connect')
it's related?
I followed this example, using the 'client' code:
https://github.com/Rapsssito/react-native-tcp-socket/blob/master/examples/tcpsockets/App.js
from react-native-tcp-socket.
@manumaso, thanks for the feedback! Could you try two things?
- First try with
cd android
and run./gradlew clean
. - If it doesn't work try to reinstall your
node_modules
.
from react-native-tcp-socket.
@ivantacca, could you provide your package.json and the steps you followed to install
react-native-tcp-socket
?
Hi, I have just tried again and I'm still getting the same error
import * as React from 'react';
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';
import TcpSocket from 'react-native-tcp-socket';
export default class App extends React.Component {
_connect = () => {
client = TcpSocket.createConnection({
host: "192.168.1.107",
port: "80"
});
}
render(){
return(
<View style={styles.container}>
<TouchableOpacity
style={styles.button}
onPress={this._connect}
>
<Text>Connect</Text>
</TouchableOpacity>
</View>
);
};
}
{
"name": "Socket_App",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-tcp-socket": "^3.5.0"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/runtime": "^7.9.2",
"@react-native-community/eslint-config": "^1.0.0",
"babel-jest": "^25.3.0",
"eslint": "^6.8.0",
"jest": "^25.3.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.11.0"
},
"jest": {
"preset": "react-native"
}
}
I've used yarn add react-native-tcp-socket
for the installation
from react-native-tcp-socket.
@manumaso, thanks for the feedback! Could you try two things?
- First try with
cd android
and run./gradlew clean
.- If it doesn't work try to reinstall your
node_modules
.
@ivantacca, could you try that and reply, pls?
from react-native-tcp-socket.
@manumaso, thanks for the feedback! Could you try two things?
* First try with `cd android` and run `./gradlew clean`. * If it doesn't work try to reinstall your `node_modules`.
I tried it several times but it still doesn't work, at the moment of executing the code that involves the library it throws the same error
TypeError: null is not an object (evaluating 'Sockets.connect')
in line
'connect' TcpSocket.js: 152:13
Maybe it's something related with expo? I ejected expo from my project, although the application starts well, it crashes when I use the library.
from react-native-tcp-socket.
@manumaso, this problem is related to the library linking because RN is not able to find the module. It is probably caused by a cache/node_module/pods bad synchronization after the automatic RN linking. I don't have experience with Expo, so I don't know the exact steps you should follow.
My advise is to reset/reinstall the library, node_modules folder, metro cache, Gradle cache and pods (and probably de PC). I hope it works, reply if the issue still persists.
from react-native-tcp-socket.
@manumaso, thanks for the feedback! Could you try two things?
- First try with
cd android
and run./gradlew clean
.- If it doesn't work try to reinstall your
node_modules
.Worked for me! Thanks!
have to try this two things please tell me
from react-native-tcp-socket.
Related Issues (20)
- java.lang.IllegalArgumentException Tcp Sockets: No socket with id HOT 4
- Cannot destroy the connection from timeout while connecting HOT 2
- Wrong error message on iOS ("error in connect() function") HOT 1
- Nmap port scan crashes the entire app on iOS 16 HOT 2
- tls authentication support ? HOT 2
- Question how to i perform tls authentication handshake HOT 1
- java.io.IOException: Interface wifi unreachable HOT 1
- Socket remains open after reloading in react-native HOT 1
- android close on reload HOT 1
- How to set up cross domain on the server HOT 1
- How to reconnect immediately to the same socket instance HOT 3
- Bug on TcpSocket.createConnection after creating/destroying 4/5 times HOT 3
- TypeError: Cannot read property 'connect' of null, js engine: hermes HOT 5
- net.createServer(options, listener) is not supported
- Using a pinned certificate will always incorrectly trust peer on iOS HOT 1
- server.on(connection , socket => {} ) not working
- Minor inconsistency with node's net api HOT 1
- Request: Support React Native Architure
- Attempt to invoke virtual method 'java.io.InputStream java.net.Socket.getInputStream()' on a null object reference HOT 3
- TLS Connection
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-tcp-socket.