Connection to remote host using legacy mode does not work

I am using libvirt-python version 8.9.0 and when I try to connect to a remote host using extra parameters after the question mark ...?mode=legacy I am still getting the error that the modular socket file is not found. This is a URI I am using:

qem+ssh://user@192.168.1.140/session?mode=legacy. (or qem+ssh://user@192.168.1.140/system?mode=legacy)

I am using Ubuntu 22.04 and most of the other distros are still using monolithic daemons, not the new modular one. The URI above works with virsh so there must be something wrong with this python library.