Closed a613 closed 2 years ago
@a613, could you test if the example code works for your setup?
Yes but it does not work if I change it to talk to a real server like google or my API server. Then it immediately fails with socketDidDisconnect with nil clientDelegate for 0
.
function init() {
// server.on('connection', (socket) => {
// socket.write('Echo server\r\n');
// });
// server.listen({ port: 0, host: '127.0.0.1', reuseAddress: true }, () => {
// const port = server.address()?.port;
// if (!port) throw new Error('Server port not found');
client.connect(
{
port: 80,
host: 'google.com',
// localAddress: '127.0.0.1',
reuseAddress: true,
// localPort: 20000,
// interface: "wifi",
// tls: true
},
() => {
client.write('GET /');
}
);
// });
@a613, you might want to take a look at #95. However, to sum up, it is an issue on your side: you must append CR + LF (\r\n) to the message you are sending.
Description
Client does not work.
Steps to reproduce
npx react-native init fresh --template react-native-template-typescript
yarn add react-native-tcp-socket
Add this to
index.js
:Run the app, see the warning and no logging of any inbound message from the server.
Current behavior
Upon init, the client logs a warning and does not communicate with the server.
Expected behavior
Upon init, the client does what the docs say. It should behave the same as
telnet google.com 80
does when sent an initial line ofGET /
.Screenshots
N/A
Relevant information