Rapsssito / react-native-tcp-socket

React Native TCP socket API for Android, iOS & macOS with SSL/TLS support.
MIT License
315 stars 82 forks source link

[Android] onClose event not firing on both sockets #16

Closed micahbule closed 4 years ago

micahbule commented 4 years ago

Description

close event for either client nor server doesn't fire when the other device disconnects.

Steps to reproduce

Steps to reproduce the behavior:

  1. Instantiate a TcpServer on device1 and register an event listener to the close event of the connecting socket.
  2. Create a TcpClient on device2, connect it to device1, and register an event listener to the close event of the client socket.
  3. Call .close() on either the socket connected to the TcpServer, or the one created by the TcpClient.

Current behavior

If you call .close() on the socket connected to the TcpServer, only the event listener on the TcpServer will fire, not the one if the TcpClient. Vice versa.

Expected behavior

Calling .close() on the socket will fire both the close event listeners registered on the server and client.

Relevant information

OS Android
react-native 0.61.4
react-native-tcp-socket 3.1.2
Rapsssito commented 4 years ago

@micahbule, thanks for the issue! Working on it!

Rapsssito commented 4 years ago

I have a fix ready. @micahbule, could you tell me if this is also reproducible in iOS?

micahbule commented 4 years ago

@Rapsssito I haven't tried it on iOS as I don't have a device to try it with.

Rapsssito commented 4 years ago

I will release an Android fix since I don't have enough time to debug iOS right now.

micahbule commented 4 years ago

Sure thing. I'll try to reproduce it on iOS if I have time. Thanks so much!

Rapsssito commented 4 years ago

Should be fixed in 3.1.3. Feel free to reopen this issue if the problem persists.