problem with service : Error: Message did not receive a reply (timeout by message bus)

amol gajewar amol_gajewar at yahoo.co.in
Wed Mar 7 20:56:37 PST 2007


hi 
I am launching one service through client and trying to invoke method 
exposed by service to message bus, but i am getting following error,

Error: Message did not receive a reply (timeout by message bus)

Following is code 

server.c

#include <stdio.h>
#include <glib-object.h>
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
#include "server.h"

static gboolean my_server_many_args()
{
    if(1)
    {
        FILE* fp;
        fp = fopen("nefile","w");
        fclose(fp);
        printf("\nmy_server_many_args\n");     
        return TRUE;        
    }
    return FALSE;
}

#include "my-server-glue.h"



static GMainLoop *loop;
DBusGConnection *connection;
static MyServer *server;

G_DEFINE_TYPE(MyServer, my_server, G_TYPE_OBJECT);

/* Class init */
static void
my_server_class_init (MyServerClass *my_server_class)
{
  //g_type_class_add_private (e_data_book_factory_class, sizeof (EDataBookFactoryPrivate));
  printf("\ni am class init\n");
  dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (my_server_class), &dbus_glib__object_info);
}

/* Instance init */
static void
my_server_init (MyServer *server)
{
}



int
main (int argc, char **argv)
{
      
  
  GError *error = NULL;
  DBusGProxy *proxy;
  char req_name = {"amol.gajewar"};
  guint32 request_name_ret,flags;

  g_type_init ();

  loop = g_main_loop_new (NULL, FALSE);
 
  /* Obtain a connection to the session bus */
  //connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
  connection = dbus_g_bus_get (getenv("DBUS_STARTER_ADD"),&error);
 
  if (connection == NULL)
  {
      printf("\nFailed to open connection to bus\n");
  }    

  proxy = dbus_g_proxy_new_for_name (connection,
                                     DBUS_SERVICE_DBUS,
                                     DBUS_PATH_DBUS,
                                     DBUS_INTERFACE_DBUS);
    
 
 
#if 1

  if(!org_freedesktop_DBus_request_name (proxy, "com.example", 0, &request_name_ret, &error))
  {
   g_warning ("There was an error requesting the name: %s", error->message); g_error_free (error); return FALSE;
  }

#endif


  server = g_object_new (TYPE_MY_SERVER, NULL);

  dbus_g_connection_register_g_object (connection,"/com/example/MyServer", G_OBJECT (server));
  g_main_loop_run (loop);
          
  dbus_g_connection_unref (connection);
  return 0;
}


client.c

#define GETTEXT_PACKAGE
#include <dbus-1.0/dbus/dbus.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <dbus-1.0/dbus/dbus-glib.h>
#include <dbus-1.0/dbus/dbus-glib-lowlevel.h>
#include "my-server-bindings.h"



static GMainLoop *loop;

int main (int argc, char **argv)
{
  DBusGConnection *connection;
  DBusGProxy *proxy,*newproxy;    
  DBusMessage *message;    
  DBusError derror;

  GError *error;
  char **name_list;
  char **name_list_ptr;

  guint32 request_name_ret;

  g_type_init ();

 // loop = g_main_loop_new (NULL, FALSE);

  error = NULL;
  connection = dbus_g_bus_get (DBUS_BUS_SESSION,
                               &error);
 
  if (connection == NULL)
    {
      g_printerr ("Failed to open connection to bus: %s\n",
                  error->message);
      g_error_free (error);
      exit (1);
    }

 /* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */
 #if 1 
  newproxy = dbus_g_proxy_new_for_name (connection,
                                     DBUS_SERVICE_DBUS,
                                     DBUS_PATH_DBUS,
                                     DBUS_INTERFACE_DBUS);

#if 1
  dbus_error_init (&derror);
printf("\nstarting\n");
  if (!dbus_bus_start_service_by_name (dbus_g_connection_get_connection (connection),
                                       "com.example",
                                       0, NULL, &derror)) {
    dbus_set_g_error (error, &derror);
    dbus_error_free (&derror);
    printf("\n i am failed 1 \n");
    g_printerr ("Error: %s\n", error->message);
    return FALSE;
  }
printf("\nstarted\n");
#endif
  /* Call ListNames method, wait for reply */
  error = NULL;
  if (!dbus_g_proxy_call (newproxy, "ListNames", &error, G_TYPE_INVALID,
                          G_TYPE_STRV, &name_list, G_TYPE_INVALID))
    {
      /* Just do demonstrate remote exceptions versus regular GError */
      if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
        g_printerr ("Caught remote method exception %s: %s",
                dbus_g_error_get_name (error),
                error->message);
      else
        g_printerr ("Error: %s\n", error->message);
      g_error_free (error);
      exit (1);
    }
  /* Print the results */
 
  g_print ("Names on the message bus:\n");
  
  for (name_list_ptr = name_list; *name_list_ptr; name_list_ptr++)
    {
      g_print ("  %s\n", *name_list_ptr);
    }
  g_strfreev (name_list);

  
#endif
#if 1
   proxy = dbus_g_proxy_new_for_name_owner (connection,"com.example","/com/example/MyServer","com.example.MyServer",   &error);

   if (!proxy) {
        g_printerr ("Error: %s\n", error->message);
    printf("i am failed 2  ");
      return FALSE;
    }



 if(!com_example_MyServer_many_args (proxy,&error))
   {    
      printf("\ni am failed\n");
    
      /* Just do demonstrate remote exceptions versus regular GError */
      if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
        g_printerr ("Caught remote method exception %s: %s",
                dbus_g_error_get_name (error),
                error->message);
      else
        g_printerr ("Error: %s\n", error->message);
      g_error_free (error);
      exit (1);
    }

#endif
  

  g_object_unref (newproxy);
  g_object_unref (proxy);
  return 0;
}


any pointers on this are welcome






 				
---------------------------------
 Here’s a new way to find what you're looking for - Yahoo! Answers 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20070308/012b1acb/attachment.html


More information about the dbus mailing list