PeelTechnologies / react-native-tcp

node's net api in react-native
MIT License
284 stars 212 forks source link

Says that socket.connect() is undefined? #81

Open galennare opened 6 years ago

galennare commented 6 years ago

When I attempt to connect to a socket it says undefined is not an object (evaluating 'Sockets.connect') in my react native app, when it clearly isn't undefined, as doing a console.log(client.connect) gives [Function anonymous], and the debugger explicitly prints that my socket is connecting to its target. (socket-1 connecting, host: 192.168.0.21 port: 5668, presumably coming from said 'connect' function).

rolodex commented 6 years ago

same issue happening for me although the error I am seeing is 'Cannot read property 'connect' of undefined'

`initSocket (){ console.log('Starting connection...');

    let socketClient = new net.Socket();

    socketClient.connect(8080, socketURL, function() {
        console.log('Connected');
        //client.write('Hello, server! Love, Client.');
    });

    socketClient.on('data', function(data) {
        console.log('Received: ' + data);
        socketClient.destroy(); // kill client after server's response
    });
    socketClient.on('close', function() {
        console.log('Connection closed');
    });

    this.setState({tuningSocket: socketClient})
}`
rolodex commented 6 years ago

are you targetting android, ios or windows?

galennare commented 6 years ago

Currently targeting android using Expo

On Sun, Jul 8, 2018, 12:06 AM rolodex notifications@github.com wrote:

are you targetting android, ios or windows?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PeelTechnologies/react-native-tcp/issues/81#issuecomment-403260725, or mute the thread https://github.com/notifications/unsubscribe-auth/AcokslcDAFZW2_562JhyPCdOkzxt99j4ks5uEYUvgaJpZM4UqtEr .

kadli01 commented 5 years ago

i have the same problem

pstanton commented 5 years ago

pretty sure this won't work on expo

maedox commented 5 years ago

pretty sure this won't work on expo

@pstanton, could you elaborate? I need TCP-sockets in my Expo app and this module seems like the only way. Would you happen to know of a solution?

maedox commented 5 years ago

@VoxelBuster @rolodex @kadli01, did anyone of you ever find a solution?

galennare commented 5 years ago

Nope, never did. Ended up using a different solution.

On Wed, Feb 27, 2019, 4:09 PM Pål Nilsen notifications@github.com wrote:

@VoxelBuster https://github.com/VoxelBuster @rolodex https://github.com/rolodex @kadli01 https://github.com/kadli01, did anyone of you ever find a solution?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PeelTechnologies/react-native-tcp/issues/81#issuecomment-468031531, or mute the thread https://github.com/notifications/unsubscribe-auth/Acoksi8zxK7no5zjyba5lZ3wzYCRNnELks5vRvQIgaJpZM4UqtEr .

Sam-Hoult commented 5 years ago

Nope, never did. Ended up using a different solution. On Wed, Feb 27, 2019, 4:09 PM Pål Nilsen @.***> wrote: @VoxelBuster https://github.com/VoxelBuster @rolodex https://github.com/rolodex @kadli01 https://github.com/kadli01, did anyone of you ever find a solution? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#81 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/Acoksi8zxK7no5zjyba5lZ3wzYCRNnELks5vRvQIgaJpZM4UqtEr .

What was your different solution?

galennare commented 5 years ago

Ended up not using react native altogether and went with Android Java

On Fri, Mar 15, 2019, 6:29 PM SamLand notifications@github.com wrote:

Nope, never did. Ended up using a different solution. … <#m-4897593111920764534> On Wed, Feb 27, 2019, 4:09 PM Pål Nilsen @.***> wrote: @VoxelBuster https://github.com/VoxelBuster https://github.com/VoxelBuster @rolodex https://github.com/rolodex https://github.com/rolodex @kadli01 https://github.com/kadli01 https://github.com/kadli01, did anyone of you ever find a solution? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#81 (comment) https://github.com/PeelTechnologies/react-native-tcp/issues/81#issuecomment-468031531>, or mute the thread https://github.com/notifications/unsubscribe-auth/Acoksi8zxK7no5zjyba5lZ3wzYCRNnELks5vRvQIgaJpZM4UqtEr .

What was your different solution?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PeelTechnologies/react-native-tcp/issues/81#issuecomment-473460985, or mute the thread https://github.com/notifications/unsubscribe-auth/AcokstzIVqA6l0pRHbA7y-h23-VkxR-Tks5vXB7PgaJpZM4UqtEr .

amiresobh commented 2 years ago

to solve this u should eject from expo it worked for me

but now i am trying to open my app on browser using webpack, and i'm facing this problem again

any Idea on this?

hhj0988a commented 1 year ago

Is there anyone who solves this? I really need help ......