Establish the websocket connection to the data engine. When job_id is
    provided we're basically establishing a websocket to an existing
    program that was already started using the jobs API

    job_id: job id of a running program

def __wss_connect(data_url,
                  token_manager,
                  job_id=None):
    """
    Establish the websocket connection to the data engine. When job_id is
    provided we're basically establishing a websocket to an existing
    program that was already started using the jobs API

    job_id: job id of a running program
    """
    url = '%s/api/v1/juttle/channel' % data_url.replace('https://', 'wss://')

    token_obj = {
        "accessToken": token_manager.get_access_token()
    }

    if job_id != None:
        token_obj['job_id'] = job_id

    if is_debug_enabled():
        debug("connecting to %s", url)

    websocket = create_connection(url)
    websocket.settimeout(10)

    if is_debug_enabled():
        debug("sent %s", json.dumps(token_obj))

    websocket.send(json.dumps(token_obj))
    return websocket