LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-14-2012, 07:24 PM   #1
silverair
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Rep: Reputation: Disabled
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
 
Old 04-14-2012, 07:31 PM   #2
uhelp
Member
 
Registered: Nov 2011
Location: Germany, Bavaria, Nueremberg area
Distribution: openSUSE, Debian, LFS
Posts: 205

Rep: Reputation: 43
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.

Last edited by uhelp; 04-14-2012 at 07:33 PM.
 
Old 04-14-2012, 07:34 PM   #3
silverair
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by uhelp View Post
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.
 
Old 04-14-2012, 07:36 PM   #4
silverair
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by uhelp View Post
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?
 
Old 04-14-2012, 08:07 PM   #5
uhelp
Member
 
Registered: Nov 2011
Location: Germany, Bavaria, Nueremberg area
Distribution: openSUSE, Debian, LFS
Posts: 205

Rep: Reputation: 43
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?
 
Old 04-14-2012, 09:34 PM   #6
silverair
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by uhelp View Post
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 View Post
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
 
Old 04-15-2012, 04:46 AM   #7
silverair
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
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?

Last edited by silverair; 04-15-2012 at 04:47 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] i cant open UDP + TCP with our passthru cURL script, but TCP works just not both?? Good Question Linux - Networking 1 10-21-2011 11:57 AM
slow tcp on 100mbps wan, strange tcp window behaviour on ubuntu 9.10 cputoaster Linux - Networking 2 03-10-2010 12:43 AM
dbus "rm /var/run/dbus/Desktop can't remove..." longus Slackware 6 12-15-2008 03:33 AM
Fedora Core 9 update dbus.exception & dbus.proxies & DBus.Error.AccessDenied errors trien27 Fedora 1 12-08-2008 11:23 PM
Linux change TCP kernel Parameter for TCP DELAY ACK TICKS linux_mando Linux - Networking 5 08-22-2006 08:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration