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

java.lang.IllegalArgumentException Tcp Sockets: No socket with id #167

Closed
pajkho opened this issue Jan 22, 2023 · 7 comments
Closed

java.lang.IllegalArgumentException Tcp Sockets: No socket with id #167

pajkho opened this issue Jan 22, 2023 · 7 comments
Labels
bug Something isn't working released

Comments

@pajkho
Copy link

pajkho commented Jan 22, 2023

Description

Sometimes when the connection gets interrupted while writing data the app will crash with "No socket with id" error. I suspect that this might be due to the write method not catching the errors that is thrown by getTcpClient method.

Steps to reproduce

Steps to reproduce the behavior:

  1. Write on the socket while it simultaneously gets disconnected.

Current behavior

App crashes with error

Expected behavior

Connection can close but app should not crash.

Relevant information

OS no
react-native yes
react-native-tcp-socket yes
@pajkho pajkho added the bug Something isn't working label Jan 22, 2023
@Rapsssito
Copy link
Owner

@pajkho, this is a common issue if you are trying to use the socket while it has not established a connection yet. Make sure you wait for the connection callback before using the socket.

@pajkho
Copy link
Author

pajkho commented Jan 30, 2023

The issue arises for us when having continuous writes to the tcp connection which doesn't stop until the end event happens. If the connection closes there can be a gap between the close of the connection and the end event where there is new writes which causes this error and the app crashes.

Wouldn't it be more reasonable to try/catch this to prevent the app from crashing and instead call the error event? It shouldn't be possible to crash the app because you mistakenly try to write to a closed connection.

@Rapsssito
Copy link
Owner

@pajkho, indeed, I will release a fix ASAP.

github-actions bot pushed a commit that referenced this issue Feb 8, 2023
## [6.0.6](v6.0.5...v6.0.6) (2023-02-08)

### Bug Fixes

* **Android:** Avoid crash when writing on closed socket. ([466a5db](466a5db)), closes [#167](#167)
@github-actions
Copy link

github-actions bot commented Feb 8, 2023

🎉 This issue has been resolved in version 6.0.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@yang-Ann
Copy link

yang-Ann commented Jul 9, 2024

Hello, this fix is missing in version 6.1.0 socketMap.remove(cId);

link

@Rapsssito
Copy link
Owner

@yang-Ann, this fix is included in the latest version. The solution was to remove socketMap.remove(cId);.

@yang-Ann
Copy link

yang-Ann commented Jul 9, 2024 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 released
Projects
None yet
Development

No branches or pull requests

3 participants