Support TCP Client connection

I want to use TCP Client to receive and transmit data to the server. Used react-native-tcp-socket on expo but failed to run. Is there any other way to connect? Thank!

Hi @mai0214cs

There should be no problem using react-native-tcp-socket in an Expo app.

The only thing you should need to bear in mind is that it will not work in Expo Go. You will need to create a development build to use instead of Expo Go.

If you try it again and it does not work you will need to give more details than “but [it] failed to run”.

Unable to run.
Error: Cannot read property ‘connect’ of null.


import React, { Component } from "react";
import { Text, View } from "react-native";
import TcpSocket from 'react-native-tcp-socket';
import global from '../../library/global';

export default class TCPClientController extends Component {
  constructor(props) {
    const options = {
        port: global.PORTTCP,
        host: global.IPTCP
    const client = TcpSocket.createConnection(options, () => {});
    client.on('data', function(data) {
    client.on('error', function(error) {
    client.on('close', function(){
        console.log('Connection closed!');
  render() {
    return (
        <Text>Test TCP Client</Text>

Hi @mai0214cs

This is the sort of error you would get if you try to run the app in Expo Go. How are you running it? You should create a development build and run it in that instead of Expo Go.

I use expo to create the build from the link, then I download the apk file to my phone and install it still don’t run.
Do you have documentation or video on how to do this?

Vào Th 4, 10 thg 5, 2023 vào lúc 16:26 Michael Wood via Forums <> đã viết:

Did you create the build after installing react-native-tcp-socket?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.