-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-native-tcp-socket connect() not working #201
Labels
bug
Something isn't working
Comments
same problem same setup, but i got a esp8266 waiting. lol |
I was able to fix it by building the project locally with:
And modifying the following files: /package.json {
...
"react-native": {
"net": "react-native-tcp-socket",
"tls": "react-native-tcp-socket",
"fs": "react-native-tcp-socket"
}
} If you are using TypeScript add this /declaration.d.ts declare module "net" {
import TcpSockets from "react-native-tcp-socket";
export = TcpSockets;
}
declare module "tls" {
import TcpSockets from "react-native-tcp-socket";
export const Server = TcpSockets.TLSServer;
export const TLSSocket = TcpSockets.TLSSocket;
export const connect = TcpSockets.connectTLS;
export const createServer = TcpSockets.createTLSServer;
} |
I can't solve the problem |
I encountered the same problem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error in connection line: "Sockets . connect( this . _id , customOptions . host , customOptions . port , customOptions) ;"
Error msg: Cannot read properties of undefined (reading 'connect')
stack:
connect --> node_modules/react-native-tcp-socket/src/Socket.js:167:17
createConnection --> node_modules/react-native-tcp-socket/src/index.js:50:22
Steps to reproduce the behavior:
`const options = {
port: 8888,
host: '192.168.0.202',
///localAddress: '192.168.0.11',
localAddress: 'localhost',
tls: false,
reuseAddress: true,
// localPort: 20000,
// interface: "wifi",
};
// Create socket
const client = TcpSocket.createConnection(options, () => {
// Write on the socket
client.write('Hello server!');
alert('Say Hello!!!');
});
client.on('data', function(data) {
alert('message was received' + data);
});
client.on('error', function(error) {
alert(error);
});
client.on('close', function(){
alert('Connection closed!');
});`
When I launch the application 'npm run web' or 'npm run android' I get this error
On the other side I have an ESP32 prepared to receive TCP connections. From a native application in Android I connect directly using Socket. The IP and port I use is the same as the native application, in 'localAddress' I try with the real IP within the wifi (192.168.0.11), localhost and 127.0.0.1. It always shows the same error.
Esp32 never receives data (if I use socket.io Esp32 does receive data but the connection is constantly reset). Is this the typical error when wrong connection data is entered?
I am testing on Android and web
OS -> Mac Big Sur
react-native -> latest
react-native-tcp-socket -> latest
The text was updated successfully, but these errors were encountered: