GithubHelp home page GithubHelp logo

Comments (19)

ivantacca avatar ivantacca commented on May 16, 2024 1

@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 avatar manumaso commented on May 16, 2024 1

@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.

Rapsssito avatar Rapsssito commented on May 16, 2024

@nthungmta207, could you provide more info about your problem (code, OS, module version)?

from react-native-tcp-socket.

Rapsssito avatar Rapsssito commented on May 16, 2024

@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.

nthungmta207 avatar nthungmta207 commented on May 16, 2024
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.

Rapsssito avatar Rapsssito commented on May 16, 2024

@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.

nthungmta207 avatar nthungmta207 commented on May 16, 2024

I have tried but it still not working

from react-native-tcp-socket.

Rapsssito avatar Rapsssito commented on May 16, 2024

I have tried but it still not working

What error are you getting?

from react-native-tcp-socket.

nthungmta207 avatar nthungmta207 commented on May 16, 2024

87254589_2530732397200837_8332245191419232256_n

from react-native-tcp-socket.

Rapsssito avatar Rapsssito commented on May 16, 2024

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.

ivantacca avatar ivantacca commented on May 16, 2024

Has anyone found a solution for this error? Thanks!

from react-native-tcp-socket.

Rapsssito avatar Rapsssito commented on May 16, 2024

@ivantacca, could you provide your package.json and the steps you followed to install react-native-tcp-socket?

from react-native-tcp-socket.

manumaso avatar manumaso commented on May 16, 2024

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.

Rapsssito avatar Rapsssito commented on May 16, 2024

@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 avatar ivantacca commented on May 16, 2024

@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.

Rapsssito avatar Rapsssito commented on May 16, 2024

@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 avatar manumaso commented on May 16, 2024

@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.

Rapsssito avatar Rapsssito commented on May 16, 2024

@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.

roshan532 avatar roshan532 commented on May 16, 2024

@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)

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.