Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have added Empathy to the list of applications that open by default, and it's configured to auto-connect to MSN when started, but when I login to my laptop the wifi connection takes a few seconds to be ready. Before the net is up, Empathy has already started, tried to login to MSN and failed, and I can't get it to connect after that.

This seems to be a bug in Empathy, but how can I get a fix for it, or if not possible, how can I delay its start until the network is up?

share|improve this question
add comment

3 Answers

up vote 3 down vote accepted

Apparently this is a known bug in Empathy, so I decided to launch Empathy from a script that checks if the network is up (connecting to http://www.google.com, internet's true heartbeat :) If the network is not working, it will sleep for 5 seconds and retry, until it tried 30 times

This is the script (named waitfornet.py)

#!/usr/bin/python

from urllib2 import urlopen, URLError
from subprocess import Popen
from time import sleep
from sys import argv

MAX_TRIES = 30
DELAY = 5

if len (argv) < 2:
    print ('Check for network connectivity and run a command once the net is up')
    print ('Tries up to %d times waiting %d seconds between each try' % (MAX_TRIES, DELAY))
    print ('\nUSAGE: python waitfornet.py <command to run>')
else:
    while True:
        MAX_TRIES -= 1
        if MAX_TRIES < 0:
            raise ValueError ('Reached the max iteration count and the net is still down')

        try:
            data = urlopen('http://www.google.com')
        except URLError:
            # if there's a problem connecting to google, that must mean
            # that the net is still down, so sleep 5 seconds and try again
            print ('Internet is down... retrying...')
            sleep (DELAY)
            continue

        # if you got here it means that the urlopen succeded
        pid = Popen([argv[1], ' '.join(argv[1:])]).pid
        break

and this is how I launch it from the "Startup Applications" menu:

~/scripts/waitfornet.py empathy
share|improve this answer
add comment

It sounds like Empathy may need a patch to do this kind of thing internally. But you should be able to poke Empathy to do the right thing by disconnecting from your network and reconnect.

I've seemingly had bugs with Empathy refusing the connect to a bunch of networks at various times. But it should give a count down "Will retry in X seconds."

But that will take code and if you want it, a bug report needs to be made.

share|improve this answer
add comment

I wrote a script specifically to overcome this problem. This script (which is based on python and D-Bus) will connect empathy to the network every time when the network is online. Even if the connection goes down and reconnects, the script will automatically reconnect empathy again.

Hope you'll enjoy it. Please leave a comment if you need any improvements.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.