I'll post an answer to my own question, as I have worked out a working solution.
Note: I have sacrificed all security via SSH as it wasn't needed for development in my own LAN.
Changing DBus to listen on TCP instead unix sockets was also not possible.
Step 1
On the remote host with an example IP address 192.168.1.100 (and to which D-Bus I'd like to have access to) I run:
socat TCP-LISTEN:7272,reuseaddr,fork UNIX-CONNECT:/var/run/dbus/system_bus_socket
Now socat listens for connections on 7272 port and creates a separate thread for each client. This allows multiple connections at the same time.
Step 2
On local machine (which I'd like to connect to remote D-Bus) I run:
socat ABSTRACT-LISTEN:/tmp/custom_dbus_name,fork TCP:192.168.1.100:7272
This connects to the port exposed remotely with socat and creates a local abstract socket to which we can connect to.
Sample usage
Python:
import dbus
sysbus = dbus.bus.BusConnection("unix:abstract=/tmp/custom_dbus_name")
proxy_obj = sysbus.get_object('com.some.service.name', '/com/some/service/name')
my_interface = dbus.Interface(proxy_obj, dbus_interface = 'com.some.interface.name')
my_interface.SomeDBusExposedMethod()
my_interface.OtherRemoteMethod()
D-Feet
One can also use D-Feet to browse remote D-Bus services and their methods. It can be done with "File / Connect to other bus" menu option and putting your custom abstract socket name defined in second step.
It would appear that your assumption is that haproxy
will add a
Connection: keep-alive
header. That is not the case. Instead, the keep-alive
mode (KAL
, default in 1.5.x) will just refrain from closing connections or adding Connection: close
headers.
Your configuration is probably fine. You can test keepalive using nc
for example, or ab -k
.
Best Answer
The best option is obviously to reconfigure your router/modem so that it won't take your internet connection offline during the hours you need it to be online.