Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In version 5, withAutoConnect(false) appears broken. #238

Closed
brett-smith opened this issue Oct 10, 2023 · 2 comments
Closed

In version 5, withAutoConnect(false) appears broken. #238

brett-smith opened this issue Oct 10, 2023 · 2 comments

Comments

@brett-smith
Copy link
Contributor

I think something is now up with withAutoConnect(false) in the latest code.

This on it's own ...

var bldr = DBusConnectionBuilder.forAddress(baddr);
bldr.transportConfig().withAutoConnect(false);

var conx = bldr.build();
conx.connect();

.. does not work, resulting in an exception when build() is called.

org.freedesktop.dbus.exceptions.DBusException: Not Connected
	at [email protected]/org.freedesktop.dbus.connections.impl.DBusConnection.connect(DBusConnection.java:98)
	at [email protected]/org.freedesktop.dbus.connections.impl.DBusConnectionBuilder.build(DBusConnectionBuilder.java:202)
	at com.sshtools.djfeet.ui/com.sshtools.djfeet.ui.NewBusPage.run(NewBusPage.java:203)

You have to do this ...

var bldr = DBusConnectionBuilder.forAddress(baddr);
bldr.withRegisterSelf(false);
bldr.transportConfig().withAutoConnect(false);

var conx = bldr.build();
conx.connect();

This connects fine, but it means the Hello() was never sent and any subsequent messages are just going to fail. As far as I can tell, its not possible to send the hello myself either, as an internal list is updated at that point.

Incidentally, the reason I tried without auto-connect in the first place was to get some control over exceptions. I have an external transport (you may remember i mentioned an SSH transport before). If that SSH connection fails for a reason I know a retry will not help, I have to now throw a some unchecked exception (e.g. IllegalStateException) instead of IOException which seems to make it try again. I can defeat this behaviour by setting TransportConfig.setTimeout() to exactly 500.

hypfvieh added a commit that referenced this issue Oct 11, 2023
…ter' to DBusConnection to allow registering session manually when it was created with 'registerSelf' = 'false'
@hypfvieh
Copy link
Owner

Thanks for the report. I reviewed the part and updated the code. Please take a look.

@brett-smith
Copy link
Contributor Author

Perfect. It now acts exactly as I'd expect. Closing.

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

No branches or pull requests

2 participants