Skip to content

system: raise in connect() when mavsdk_server exits - #843

Merged
julianoes merged 1 commit into
mavlink:mainfrom
bansiesta:connect-fail-when-mavsdk-server-exits
Nov 30, 2026
Merged

julianoes merged 1 commit into
mavlink:mainfrom
bansiesta:connect-fail-when-mavsdk-server-exits

Conversation

@bansiesta

@bansiesta bansiesta commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

connect() waits for the gRPC channel with no timeout. If the embedded mavsdk_server exits first (invalid connection URL, port already in use), it hung forever.

While waiting, connect() now checks whether the server process is still running. If it has exited, it stops waiting, cleans up and raises MavsdkServerExitedError with the exit code. The reason is already logged as an error from the mavsdk_server logger (since #781).

This needs mavlink/MAVSDK#3240: mavsdk_server 4.3.0 doesn't exit on these errors, it keeps waiting without opening its gRPC port. Once that's in a release and MAVSDK_SERVER_VERSION is bumped, the hang is gone.

Testing

  • New tests in tests/test_system.py (server exits → raises; server running → waits as before). They fail without the change; all 5 pass.
  • End to end with a mavsdk_server built from mavsdk_server: exit when the connection can't be added MAVSDK#3240: udp://14540 and a busy udpin://0.0.0.0:14600 both raise after 0.2 s. With the 4.3.0 server it still hangs, as expected.

Fixes #585
Fixes #759 (udpin://:14540 has no bind address, so it's an invalid URL)

@julianoes

connect() waited for the gRPC channel to become ready without a
timeout. When the embedded mavsdk_server exited before that, e.g.
because of an invalid connection URL or a UDP port that is already in
use, connect() hung forever.

While waiting, check whether the server process is still running. If
it has exited, stop waiting and raise MavsdkServerExitedError with its
exit code. The reason is in the mavsdk_server log messages, which are
already logged as errors.

Fixes mavlink#585
@julianoes
julianoes merged commit 159411e into mavlink:main Nov 30, 2026
9 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.

MAVSDK-Python Hangs After Backend Logs "System discovered" on Ubuntu 20.04 mavsdk_server errors not shown to users

2 participants