Skip to content

CrossMgr - bug in reconnecting JChip after network disconnected and JChip timeout #186

@stuartlynne

Description

@stuartlynne

Describe the bug
Using CrossMgrImpinj to send tag data to CrossMgr, if the network connection is lost long enough for CrossMgr to disconnect and attempt to reconnect, CrossMgr throws an exception and may or may not eventually allow a reconnect.

To Reproduce
Steps to reproduce the behavior:

  1. Run CrossMgr, use ChipReader Setup, for CrossMgrImpij reader type, click "Start RFID Test"
  2. Run CrossMgrImpinj, configure to point at an Impinj reader, and at CrossMgr host (my test was two separate laptops, both running Linux, connected via Ethernet)
  3. Ensure that connection is established.
  4. Disconnect Ethernet
  5. Click Reset in CrossMgrImpinj to force disconnect
  6. Reconnect Ethernet
  7. Will see exception messages.

Additional context
I tracked this down to JChip.py, and added a traceback to the suspected exception handler.

2025-08-14T23:56:56 (v3.1.79 Linux) JChip: exception: N0000zbookg5-194349: <socket.socket fd=21, family=2, type=1, proto=0, laddr=('192.168.40.40', 53135), raddr=('192.168.40.41', 34060)>
Traceback (most recent call last):
  File "/home/sl/CrossMgr-master/JChip.py", line 268, in Server
    qLog( 'transmitting', '"{}" is reconnecting'.format(readerName[s]) )
                                                        ~~~~~~~~~~^^^
KeyError: <socket.socket fd=21, family=2, type=1, proto=0, laddr=('192.168.40.40', 53135), raddr=('192.168.40.41', 34060)>
2025-08-14T23:56:58 (v3.1.79 Linux) JChip: connection: disconnected: <unknown>
2025-08-14T23:56:58 (v3.1.79 Linux) JChip: connection: established ('192.168.40.41', 34068)
2025-08-14T23:56:58 (v3.1.79 Linux) JChip: exception: N0000zbookg5-194349: <socket.socket fd=21, family=2, type=1, proto=0, laddr=('192.168.40.40', 53135), raddr=('192.168.40.41', 34068)>
Traceback (most recent call last):
  File "/home/sl/CrossMgr-master/JChip.py", line 268, in Server

Commenting out the qLog() call appeared to resolve the issue. There may be other side effects to the KeyError issue; I didn't dig into the code far enough to see any.

Probably there is a better fix that preserves the logging without causing the exception.

diff --git a/JChip.py b/JChip.py
index f266d90e..8aad44f2 100644
--- a/JChip.py
+++ b/JChip.py
@@ -15,6 +15,7 @@ from queue import Queue, Empty
 
 import Utils
 import Model
+import traceback
 
 ChipReaderEvent, EVT_CHIP_READER = wx.lib.newevent.NewEvent()
 

@@ -264,7 +265,7 @@ def Server( q, shutdownQ, HOST, PORT, startTime ):
                                                # Close the previous connection as it is no longer needed.
                                                if name in nameReader:
                                                        s_dropped = nameReader[name]
-                                                   qLog( 'transmitting', '"{}" is reconnecting'.format(readerName[s]) )
+                                                 #qLog( 'transmitting', '"{}" is reconnecting'.format(readerName[s]) )
                                                        closeReader( s_dropped )
                                                
                                                readerName[s] = name
@@ -316,6 +317,7 @@ def Server( q, shutdownQ, HOST, PORT, startTime ):
                                                
                                except (ValueError, KeyError, IndexError) as e:
                                        qLog( 'exception', '{}: {}'.format(line, e) )
+                                 traceback.print_exc()
                                        pass
                        
                        sendReaderEvent( tagTimes )

I was looking at this because I have observed odd connection failures where CrossMgrImpinj would not be able to connect, but I had not been able to reproduce them. This may (or may not) be what I was seeing, but this does appear to be an issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions