Rapsssito / react-native-tcp-socket

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

java.io.IOException: Interface wifi unreachable #176

Closed ricardordzalt closed 1 year ago

ricardordzalt commented 1 year ago

Description

The application closes without displaying any error message when trying to create a connection to an unreachable interface.

Steps to reproduce

  1. Specify the interface as "wifi" in the connection options.
  2. Use the createConnection function with the Wi-Fi disabled on device .

import TcpSocket from 'react-native-tcp-socket';

TcpSocket.createConnection({
  port: 8899, // or any
  host: '192.168.100.1', // or any
  interface: 'wifi',
}, () => {})

Current behavior

App closes without error on metro. adb logcat shows next code

providerId 0 06-20 15:04:52.577 521 553 D WifiNl80211Manager: Scan result ready event 06-20 15:04:52.577 521 553 D WifiNative: Scan result ready event 06-20 15:04:54.852 739 739 D StatusBar: disable<e i a s b h r c s > disable2<q i n > 06-20 15:04:54.897 739 739 D StatusBar: disable<e i a s b h r c s > disable2<q i n > 06-20 15:04:55.894 458 458 E netmgr : qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:network' service: Invalid argument 06-20 15:04:55.894 458 458 E netmgr : Failed to open QEMU pipe 'qemud:network': Invalid argument 06-20 15:04:56.026 462 462 E wifi_forwarder: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:wififorward' service: Invalid argument 06-20 15:04:56.026 462 462 E wifi_forwarder: RemoteConnection failed to initialize: RemoteConnection failed to open pipe 06-20 15:04:57.378 11109 11218 E TcpSockets: Exception on socket 0 06-20 15:04:57.378 11109 11218 E TcpSockets: java.io.IOException: Interface wifi unreachable 06-20 15:04:57.378 11109 11218 E TcpSockets: at com.asterinet.react.tcpsocket.TcpSocketModule.selectNetwork(TcpSocketModule.java:273) 06-20 15:04:57.378 11109 11218 E TcpSockets: at com.asterinet.react.tcpsocket.TcpSocketModule.access$300(TcpSocketModule.java:28) 06-20 15:04:57.378 11109 11218 E TcpSockets: at com.asterinet.react.tcpsocket.TcpSocketModule$1.run(TcpSocketModule.java:79) 06-20 15:04:57.378 11109 11218 E TcpSockets: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 06-20 15:04:57.378 11109 11218 E TcpSockets: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 06-20 15:04:57.378 11109 11218 E TcpSockets: at java.lang.Thread.run(Thread.java:923) 06-20 15:04:57.392 11109 11211 I ReactNativeJS: Interface wifi unreachable 06-20 15:04:57.397 11109 11226 E AndroidRuntime: FATAL EXCEPTION: pool-10-thread-2 06-20 15:04:57.397 11109 11226 E AndroidRuntime: Process: com.tcpsockettest, PID: 11109 06-20 15:04:57.397 11109 11226 E AndroidRuntime: java.lang.IllegalArgumentException: No socket with id 0 06-20 15:04:57.397 11109 11226 E AndroidRuntime: at com.asterinet.react.tcpsocket.TcpSocketModule.getTcpClient(TcpSocketModule.java:281) 06-20 15:04:57.397 11109 11226 E AndroidRuntime: at com.asterinet.react.tcpsocket.TcpSocketModule.access$800(TcpSocketModule.java:28) 06-20 15:04:57.397 11109 11226 E AndroidRuntime: at com.asterinet.react.tcpsocket.TcpSocketModule$2.run(TcpSocketModule.java:125) 06-20 15:04:57.397 11109 11226 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 06-20 15:04:57.397 11109 11226 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 06-20 15:04:57.397 11109 11226 E AndroidRuntime: at java.lang.Thread.run(Thread.java:923) 06-20 15:04:57.404 521 11228 I DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2 06-20 15:04:57.407 521 2705 W ActivityTaskManager: Force finishing activity com.tcpsockettest/.MainActivity 06-20 15:04:57.418 322 367 D goldfish-address-space: claimShared: Ask to claim region [0x3f6ef9000 0x3f74fc000] 06-20 15:04:57.448 521 4815 D HostConnection: HostConnection::get() New Host Connection established 0xf6ef48f0, tid 4815 06-20 15:04:57.450 11109 11226 I Process : Sending signal. PID: 11109 SIG: 9 06-20 15:04:57.460 521 564 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver 06-20 15:04:57.461 521 564 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver 06-20 15:04:57.468 521 564 I ActivityManager: Killing 9688:com.google.android.setupwizard/u0a99 (adj 985): empty #17 06-20 15:04:57.536 302 302 I Zygote : Process 11109 exited due to signal 9 (Killed) 06-20 15:04:57.535 521 4815 D HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_0 06-20 15:04:57.544 521 4815 W OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 06-20 15:04:57.546 521 4815 D EGL_emulation: eglCreateContext: 0xf6efd870: maj 3 min 0 rcv 3 06-20 15:04:57.547 521 4815 D EGL_emulation: eglMakeCurrent: 0xf6efd870: ver 3 0 (tinfo 0xbe14a4b0) (first time) 06-20 15:04:57.626 521 827 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ LISTEN id=71, [ Transports: WIFI Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN Uid: 10099 AdministratorUids: [] RequestorUid: 10099 RequestorPackageName: com.google.android.setupwizard] ], android.os.BinderProxy@172cb1c) 06-20 15:04:57.627 302 302 I Zygote : Process 9688 exited due to signal 9 (Killed) 06-20 15:04:57.635 739 755 I ndroid.systemu: NativeAlloc concurrent copying GC freed 77681(3171KB) AllocSpace objects, 3(60KB) LOS objects, 49% free, 7693KB/15MB, paused 110us total 174.713ms 06-20 15:04:57.641 521 2705 I ActivityManager: Process com.tcpsockettest (pid 11109) has died: prcp TOP 06-20 15:04:57.641 521 827 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ REQUEST id=85, [ Transports: WIFI Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN Uid: 10154 AdministratorUids: [] RequestorUid: 10154 RequestorPackageName: com.tcpsockettest] ], android.os.BinderProxy@70252ab) 06-20 15:04:57.641 521 1783 D ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ REQUEST id=84, [ Transports: WIFI Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN Uid: 10154 AdministratorUids: [] RequestorUid: 10154 RequestorPackageName: com.tcpsockettest] ], android.os.BinderProxy@9d83cfa) 06-20 15:04:57.641 521 675 D ConnectivityService: releasing NetworkRequest [ REQUEST id=85, [ Transports: WIFI Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN Uid: 10154 AdministratorUids: [] RequestorUid: 10154 RequestorPackageName: com.tcpsockettest] ] (release request) 06-20 15:04:57.643 521 675 D ConnectivityService: releasing NetworkRequest [ REQUEST id=84, [ Transports: WIFI Capabilities: NOT_RESTRICTED&TRUSTED&NOT_VPN Uid: 10154 AdministratorUids: [] RequestorUid: 10154 RequestorPackageName: com.tcpsockettest] ] (release request) 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_9 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_7 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_10 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_4 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_11 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_5 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_2 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_6 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_3 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.658 521 2705 W InputReader: Device virtio_input_multi_touch_8 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.660 521 2705 W InputReader: Device virtio_input_multi_touch_9 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.660 521 2705 W InputReader: Device virtio_input_multi_touch_7 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.660 521 2705 W InputReader: Device virtio_input_multi_touch_10 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.660 521 2705 W InputReader: Device virtio_input_multi_touch_4 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.660 521 2705 W InputReader: Device virtio_input_multi_touch_11 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.660 521 2705 W InputReader: Device virtio_input_multi_touch_5 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.661 521 2705 W InputReader: Device virtio_input_multi_touch_2 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.661 521 2705 W InputReader: Device virtio_input_multi_touch_6 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.661 521 2705 W InputReader: Device virtio_input_multi_touch_3 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.661 521 2705 W InputReader: Device virtio_input_multi_touch_8 is associated with display ADISPLAY_ID_NONE. 06-20 15:04:57.662 521 566 I libprocessgroup: Successfully killed process cgroup uid 10099 pid 9688 in 190ms 06-20 15:04:57.663 521 566 I libprocessgroup: Successfully killed process cgroup uid 10154 pid 11109 in 0ms 06-20 15:04:57.667 521 827 I WindowManager: WIN DEATH: Window{867f32b u0 com.tcpsockettest/com.tcpsockettest.MainActivity} 06-20 15:04:57.667 521 827 W InputDispatcher: Attempted to unregister already unregistered input channel '867f32b com.tcpsockettest/com.tcpsockettest.MainActivity (server)' 06-20 15:04:57.686 322 367 D goldfish-address-space: claimShared: Ask to claim region [0x3f4000000 0x3f4965000] 06-20 15:04:57.699 521 558 W ActivityManager: setHasOverlayUi called on unknown pid: 11109 06-20 15:04:57.700 322 6394 D goldfish-address-space: claimShared: Ask to claim region [0x3f52ca000 0x3f5c2f000] 06-20 15:04:57.701 521 1634 W ActivityManager: Unable to start service Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } U=0: not found 06-20 15:04:57.701 521 1634 W RemoteAppPredictionService: could not bind to Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } using flags 67108865 06-20 15:04:57.714 322 6394 D goldfish-address-space: claimShared: Ask to claim region [0x3f5c2f000 0x3f6594000] 06-20 15:04:57.722 322 367 D goldfish-address-space: claimShared: Ask to claim region [0x3fae0c000 0x3fb771000] 06-20 15:04:57.731 9980 9980 I A : onStart 06-20 15:04:57.737 322 367 D goldfish-address-space: claimShared: Ask to claim region [0x3f9c80000 0x3fa5e5000] 06-20 15:04:57.738 9980 9980 I A : onResume 06-20 15:04:57.746 322 6394 D goldfish-address-space: claimShared: Ask to claim region [0x3f8000000 0x3f8965000] 06-20 15:04:57.750 9271 9271 I GsaVoiceInteractionSrv: Handling ACTION_START_HOTWORD 06-20 15:04:57.757 9271 9350 I GsaVoiceInteractionSrv: (REDACTED) disregardHotwordSetting: %b 06-20 15:04:57.757 9271 9350 I GsaVoiceInteractionSrv: Cannot start hotword, hotword has been explicitly disabled.

Expected behavior

App doesn't crash, and the 'error' event is triggered with the message "Interface wifi unreachable" or similar.

Relevant Information

Enviroment:

OS: android react-native version: 0.71.11 react-native-tcp-socket version: 6.0.6

Error also occurs with other interfaces

github-actions[bot] commented 1 year ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.