Skip to content
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

iOS: No client found with id X #64

Closed
deiv23 opened this issue Jul 6, 2020 · 6 comments
Closed

iOS: No client found with id X #64

deiv23 opened this issue Jul 6, 2020 · 6 comments
Labels
bug Something isn't working iOS

Comments

@deiv23
Copy link

deiv23 commented Jul 6, 2020

Description

I have problems on IOS, when I try to reuse the socket I receive:
Error in connect() function
no client found with id X

Dependencies

react-native 0.61.5
react-native-tcp-socket 3.2.4

Steps to reproduce the behavior:

calling a function like this twice.

function send()
{
         var options = {port:4444, host: x.x.x.x, reuseAddress:true, localAdress: y.y.y.y, localPort:4445}

         var client = TcpSocket.createConnection(options);
         client.on('error', function(error) {
             console.log(error)
         });
         client.on('data', function(data) {
             client.destroy();
         });
         client.write(JSON.stringify(jsArray));
}

Current behavior

if I execute the send() function once, everything works ok
second time gives the error:
Error in connect() function
no client found with id X

In android works ok every time.

Expected behavior

work ok on second try

@Rapsssito Rapsssito changed the title no client found with id X - template iOS: No client found with id X Jul 6, 2020
@Rapsssito Rapsssito added bug Something isn't working iOS labels Jul 6, 2020
@Rapsssito
Copy link
Owner

Rapsssito commented Jul 6, 2020

@deiv23, you are calling the socket before it has been created. You have to use the callback provided by TcpSocket.createConnection():

var options = {port:4444, host: x.x.x.x, reuseAddress:true, localAdress: y.y.y.y, localPort:4445}
// TcpSocket.createConnection is async
var client = TcpSocket.createConnection(options, () => {
    client.write(JSON.stringify(jsArray));
});
client.on('error', function(error) {
     console.log(error)
});
client.on('data', function(data) {
    client.destroy();
});

I will update the docs to make it clear.

@deiv23
Copy link
Author

deiv23 commented Jul 6, 2020

@Rapsssito thanks for the reply. Im trying to implement but that callback doesn't get called, I don't know why

@Rapsssito
Copy link
Owner

@deiv23, you can take a look at the example code for a more exhaustive example.

@deiv23
Copy link
Author

deiv23 commented Jul 7, 2020

@Rapsssito I have the callback working, but second time I execute the function send, the createConnection callback isn't called. No errors shown.
The server is ready to respond, I tested with an external tool after the first send, and the server is ready.

@Rapsssito
Copy link
Owner

@deiv23, it might be related to a bad config on your server or a wrong logic on your client's code. I cannot help you without any more information.

@deiv23
Copy link
Author

deiv23 commented Jul 8, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iOS
Projects
None yet
Development

No branches or pull requests

2 participants