LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Connecting to dbus over tcp (https://www.linuxquestions.org/questions/linux-newbie-8/connecting-to-dbus-over-tcp-939831/)

silverair 04-14-2012 07:24 PM

Connecting to dbus over tcp
 
I wrote a simple python program to play and pause banshee music player.
While its working on my own machine, I have trouble doing it to a remote computer, connected to the same router (LAN).
I edited the session.conf of the remote machine, to add this line:
Code:

<listen>tcp:host=localhost,port=12434</listen>
and here is my program:
Code:

import dbus


bus_obj=dbus.bus.BusConnection("tcp:host=localhost,port=12434")

proxy_object=bus_obj.get_object('org.bansheeproject.Banshee',
                      '/org/bansheeproject/Banshee/PlayerEngine')

playerengine_iface=dbus.Interface(proxy_object,
                dbus_interface='org.bansheeproject.Banshee.PlayerEngine')
                     
var=raw_input("\nPress\n1 to play\n2 to pause\n3 to exit\n")

while (var!="3"):
        var=raw_input("\nPress\n1 to play\n2 to pause\n3 to exit\n")


        if var=="1":
                print "playing..."
                playerengine_iface.Play()
       
        elif var=="2":
                print "pausing"
                playerengine_iface.Pause()

This is what i get when i try to execute it
Traceback (most recent call last):
File "dbus3.py", line 4, in <module>
bus_obj=dbus.bus.BusConnection("tcp:host=localhost,port=12434")
File "/usr/lib/python2.7/dist-packages/dbus/bus.py", line 125, in __new__
bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoServer: Failed to connect to socket "localhost:12434" Connection refused

What am I doing wrong here?
should i edit /usr/lib/python2.7/dist-packages/dbus/bus.py

uhelp 04-14-2012 07:31 PM

How did you make "dbus" listen to that port on the other machine?

Editing standard packages is a no-go.
The failure is always in your script or at layer 8
and only in very, very rare cases in the standard modules.

silverair 04-14-2012 07:34 PM

Quote:

Originally Posted by uhelp (Post 4652873)
How did you make "dbus" listen to that port on the other machine?

like I said,
I added this line to session.conf of the remote machine:

<listen>tcp:host=localhost,port=12434</listen>

obviously, I am doing something wrong here?
apologies if it is a stupid mistake.

silverair 04-14-2012 07:36 PM

Quote:

Originally Posted by uhelp (Post 4652873)
How did you make "dbus" listen to that port on the other machine?

Editing standard packages is a no-go.
The failure is always in your script or at layer 8
and only in very, very rare cases in the standard modules.

ok, so how do I fix this?

uhelp 04-14-2012 08:07 PM

I doubt you can do that at all.

But having
....BusConnection("tcp:host=localhost,port=12434")
it just can't even try to connect.
Change "localhost" to remote hostname or remote IP

"dbus" is designed for local communication.
Allbeit there are plans to extend it to network communication.
Solutions up to now just got problems with authentication.

Think about that:
What should the remote box do to avoid that someone from the alpha centauri just plays alien music?

silverair 04-14-2012 09:34 PM

Quote:

Originally Posted by uhelp (Post 4652903)
I doubt you can do that at all.

No, its definetly possible a lot of applications have done it. Unfortunately, no source code.

Quote:

Originally Posted by uhelp (Post 4652903)
But having
....BusConnection("tcp:host=localhost,port=12434")
it just can't even try to connect.
Change "localhost" to remote hostname or remote IP

is the remote hostname what you get from ifconfig? I tried it, no luck.
should i also do that for the session.conf file? (in /etc/dbus-1)
I am confused

silverair 04-15-2012 04:46 AM

ok, here is the deal
when i add
<listen>tcp:host=192.168.1.7,port=12434</listen>
to to /etc/dbus-1/session.conf, then reboot, hoping it would start listening on reboot,
It never boots. It gets stuck on loading screen and occasionally, a black screen with the following text flashes:

Pulseaudio Configured For Per-user Sessions Saned Disabled;edit/etc/default/saned
so, when i go ctrl+alt+f1 , change session.conf to original state and reboot, it boots properly.

Whats all that about?
How can I make dbus daemon listen for tcp connections, without encountering problems?


All times are GMT -5. The time now is 11:45 AM.