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

Wrong error message on iOS ("error in connect() function") #170

Closed
jesperjohansson opened this issue Jan 30, 2023 · 1 comment · Fixed by #171
Closed

Wrong error message on iOS ("error in connect() function") #170

jesperjohansson opened this issue Jan 30, 2023 · 1 comment · Fixed by #171
Labels
bug Something isn't working released

Comments

@jesperjohansson
Copy link
Contributor

On iOS you always receive the error message "error in connect() function".
By switching to localizedDescription we could get more specific error messages such as "Connection refused".

patch-package:

diff --git a/node_modules/react-native-tcp-socket/ios/TcpSockets.m b/node_modules/react-native-tcp-socket/ios/TcpSockets.m
index 23c961f..3a9783a 100644
--- a/node_modules/react-native-tcp-socket/ios/TcpSockets.m
+++ b/node_modules/react-native-tcp-socket/ios/TcpSockets.m
@@ -283,7 +283,7 @@ - (void)onClose:(NSNumber *)clientID withError:(NSError *)err {
 }
 
 - (void)onError:(TcpSocketClient *)client withError:(NSError *)err {
-    NSString *msg = err.localizedFailureReason ?: err.localizedDescription;
+    NSString *msg = err.localizedDescription ?: err.localizedFailureReason;
     [self sendEventWithName:@"error" body:@{@"id" : client.id, @"error" : msg}];
 }
@github-actions
Copy link

🎉 This issue has been resolved in version 6.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

1 participant