Failed to connect to SITL port 2

Hi, I’m very new to Mission Planner and want to explore mavlink communication between my code and SITL. I’ve started Mission Planner on my Windows host, ran a Quad sim from the UI - everything works. The console shows ports 5760, 5762, 5763 are open as serial ports, and that serial port 0 is connected to (I guess by the UI):

Setting SIM_SPEEDUP=1.000000
Suggested EK3_DRAG_BCOEF_* = 16.288, EK3_DRAG_MCOEF = 0.209
Home: -35.363352 149.165241 alt=587.060000m hdg=0.000000
Starting sketch 'ArduCopter'
Starting SITL input
Using Irlock at port : 9005
bind port 5760 for 0
Serial port 0 on TCP port 5760
Loaded defaults from C:\Users\xxxx\Mission Planner\sitl\default_params/copter.parm
bind port 5762 for 2
Serial port 2 on TCP port 5762
bind port 5763 for 3
Serial port 3 on TCP port 5763
Smoothing reset at 0.001
validate_structures:498: Validating structures
Loaded defaults from C:\Users\xxxx\Mission Planner\sitl\default_params/copter.parm
New connection on serial port 0

I am now trying to connect to port 5762 with my Python mavlink code but connect method never returns, it waits forever:

from mavsdk import System
import asyncio

async def run():
    drone = System('localhost', 5762)
    await drone.connect('tcp://localhost:5762')

if __name__ == '__main__':
    asyncio.run(run())

While waiting, SITL console shows the connection attempt being retried over and over:

New connection on serial port 2
Closed connection on serial port 2
New connection on serial port 2
Closed connection on serial port 2
...repeats forever

What am I doing wrong?

Thanks…

Did you disabled your firewall ?

No… but I have docker running, freely opening and accessing ports on localhost. I tried opening this port (5762) for some other service as a test - no problem connecting. Also, SITL shows the connection attempts, so it “breaks” at a higher level than the firewall IMO. Are you referring to this port or is there some other port here being accessed that I’m unaware of?

Disconnect Mission planner and try to connect to 5760,if it fails, then your python side has some problems…

And some advice, see this post Mavlink Libraries: Which one should I use? MavSdk is not really the native python lib for Ardupilot.