Calling remote gearman worker from local gearman client?

820 Views Asked by At

Does calling remote gearman worker from local system is possible? I tried calling using my remote azure server IP:

client on local system:

gm_client = gearman.GearmanClient(['204.43.9.41:4730'])
sent = sys.argv[1]
completed_job_request = gm_client.submit_job("load_db", sent)

remote worker :

def __init__(self):
    self.gm_worker = gearman.GearmanWorker(['204.43.9.41:4730'])
    self.context = self.init_context()
    res = self.gm_worker.register_task('load_db', self.run_query)

When I kept worker running on remote server and called from local client, it gave this error:

gearman.errors.ServerUnavailable: Found no valid connections: GearmanConnection 204.43.9.41:4730 connected=False
1

There are 1 best solutions below

0
On BEST ANSWER

There is very simple way to do this:

  1. Bind localhost gearman port with remote gearman port:

    sudo ssh -L 4730:localhost:4730 [email protected]

  2. Now keep worker running on remote server

  3. make simple call from local system

    python worker.py 'input parameter'