Skip to content

Conversation

@X9X0
Copy link
Owner

@X9X0 X9X0 commented Nov 16, 2025

Summary

Major fixes to the LabLink GUI launcher and client-server communication, resolving all connection and dependency issues on Ubuntu 24.04.

Launcher Improvements

  • ✅ All missing dependencies added (scipy, psutil, apscheduler, zeroconf, security packages)
  • ✅ Package-to-import name mappings (PyJWT→jwt, email-validator→email_validator, etc.)
  • ✅ Auto-close launch messages (3 second timeout)
  • ✅ Background fix worker (prevents GUI freezing)
  • ✅ Helper methods added to LabLinkLauncher class

Client-Server Fixes

  • ✅ Fixed JSON parsing error on connection (use /api endpoint)
  • ✅ Skip authentication when server security is disabled
  • ✅ Added missing refresh() methods to AcquisitionPanel and SyncPanel
  • ✅ Fixed async event loop integration with qasync
  • ✅ Fixed async disconnect coroutine warnings
  • ✅ Fixed equipment manager attribute error in diagnostics endpoint
  • ✅ Fixed WebSocket to use correct port (8000 not 8001)

Testing

Tested on Ubuntu 24.04:

  • ✅ Server launches successfully with all subsystems
  • ✅ Client connects without errors
  • ✅ All API endpoints responding correctly
  • ✅ No import errors or async warnings

Fixed two critical issues preventing proper client-server communication:

1. JSON parsing error on connection:
   - Changed client get_server_info() to call /api endpoint instead of /
   - Root endpoint (/) returns HTML, while /api returns JSON as expected
   - Fixes "Expecting value: line 1 column 1 (char 0)" error

2. Async coroutine warning:
   - Fixed disconnect_from_server() to properly await async disconnect()
   - Uses asyncio.create_task() to schedule the async operation
   - Eliminates "coroutine was never awaited" RuntimeWarning

3. Version consistency:
   - Updated server /api endpoint version from 0.24.0 to 0.27.0
   - Now matches actual server version shown in startup logs

Changes:
- client/api/client.py: Changed endpoint from "/" to "/api" in get_server_info()
- client/ui/main_window.py: Fixed async disconnect with asyncio.create_task()
- server/main.py: Updated API version to 0.27.0
Added _check_externally_managed() and _check_command_exists() methods
to LabLinkLauncher class. These methods were already in CheckWorker but
were being called by LabLinkLauncher.apply_fixes(), causing AttributeError.

Fixes: 'LabLinkLauncher' object has no attribute '_check_command_exists'
Fixed authentication errors when connecting to servers with security disabled:

1. Server changes:
   - Added 'security_enabled' field to /api endpoint response
   - Indicates whether advanced security system is active

2. Client changes:
   - Check security_enabled flag before attempting login
   - If disabled, connect as 'anonymous' user without authentication
   - Avoids "Expecting value: line 1 column 1" errors from missing /api/security/login endpoint
   - Updated _complete_connection to check authenticated flag directly

This allows the client to work with both secured and unsecured servers
without requiring manual configuration changes.

Fixes connection errors when server has enable_advanced_security=False (default).
Fixed three issues that appeared after successful authentication bypass:

1. Added refresh() method to AcquisitionPanel:
   - Calls refresh_sessions(silent=True)
   - Fixes AttributeError: 'AcquisitionPanel' object has no attribute 'refresh'

2. Added refresh() method to SyncPanel:
   - Calls refresh_groups(silent=True)
   - Ensures all panels have consistent refresh interface

3. Fixed async WebSocket connection:
   - Changed from asyncio.create_task() to asyncio.ensure_future() with qasync event loop
   - Fixes "coroutine was expected" and "no running event loop" errors
   - Properly integrates with qasync's Qt event loop

These errors only appeared after client successfully connected to server
(thanks to the authentication bypass fix).
Fixed two runtime errors:

1. Client async event loop error:
   - Changed from qasync.QEventLoop.instance() to asyncio.get_event_loop()
   - QSelectorEventLoop doesn't have 'instance' attribute
   - Fixes: "type object 'QSelectorEventLoop' has no attribute 'instance'"

2. Server diagnostics endpoint error:
   - Changed equipment_manager._equipment to equipment_manager.equipment
   - EquipmentManager uses 'equipment' not '_equipment' attribute
   - Fixes: "'EquipmentManager' object has no attribute '_equipment'"
   - Resolves 500 Internal Server Error on /api/diagnostics/health endpoint
Fixed WebSocket connection to use the correct port:
- Changed WebSocketManager to use api_port instead of ws_port
- The server's WebSocket endpoint is at ws://{host}:{api_port}/ws
- The server doesn't actually use the separate ws_port setting
- Fixes connection errors to port 8001 (should be 8000)

This resolves the continuous WebSocket connection retry messages.
@X9X0 X9X0 merged commit f0d2fc6 into main Nov 16, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants