Try to create new context instead nm_client_get_main_context:
GMainContext *context = g_main_context_new();