Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29606

When sending from react native tcp client to a node js tcp server, the first message is sent successfully the second throws error

$
0
0

enter image description here

Im using react-native-tcp-socket and my code is identical to what is in their docs. I am able to make a connection and send/receive one message, but when I try to connect again, I get this error. I am working on an android simulator and connecting to a node js server.

var client = TcpSocket.createConnection(options);

client.on('data', function(data) {
  console.log('message was received', data);
});

client.on('error', function(error) {
  console.log(error);
});

client.on('close', function(){
  console.log('Connection closed!');
});

// Write on the socket
client.write('COORDINATE_MOVE ELEV:' + this.state.elevation + 'AZIM:' + this.state.azimuth + 'ID:todd');

// Close socket
client.destroy();

Viewing all articles
Browse latest Browse all 29606

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>