"Connection to AUT refused"

Last edited on

Symptom

“Connection to AUT refused” when trying to launch or attach an Application, that is started on a device.

Possible Explanation

The device or the application on it is not reachable per TCP/IP.

The code below can be used to check if the AUT on the device is reachable at all.

# -*- coding: utf-8 -*-

import socket

def main():
    test_connection('localhost', 5555)

def test_connection(host, port):
    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.connect((host, port))
        test.passes("Connection successfully established")
    except socket.error as e:
        test.fail("Connection failed", e.strerror)
    except Exception as e:
        test.log(e.message)
    finally:
        sock.close()
test.py