androidtestingproxyandroidviewclient

androidviewclient - Can't connect to the device on vm with port forwarding


I forwarded localhost on vm to host machine with 80 port (8080 ip:80), avc works fine before that and now I have an error with connecting to the device:

import sys
import os

try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.viewclient import ViewClient

device, serialno = ViewClient.connectToDeviceOrExit(verbose=False)

def init():
    global device
    return device

an error:

Traceback (most recent call last):
  File "launcher.py", line 5, in <module>
    import device
  File "/home/test/www/ANDROID/device.py", line 11, in <module>
    device, serialno = ViewClient.connectToDeviceOrExit(verbose=False)
  File "/usr/local/lib/python2.7/dist-packages/androidviewclient-7.0.4-py2.7.egg/com/dtmilano/android/viewclient.py", line 1436, in connectToDeviceOrExit
    device = adbclient.AdbClient(serialno)
  File "/usr/local/lib/python2.7/dist-packages/androidviewclient-7.0.4-py2.7.egg/com/dtmilano/android/adb/adbclient.py", line 89, in __init__
    self.__connect()
  File "/usr/local/lib/python2.7/dist-packages/androidviewclient-7.0.4-py2.7.egg/com/dtmilano/android/adb/adbclient.py", line 129, in __connect
    raise RuntimeError("ERROR: Connecting to %s:%d: %s.\nIs adb running on your computer?" % (self.socket, self.port, ex))
RuntimeError: ERROR: Connecting to <socket._socketobject object at 0x7f22a2a2ac20>:5037: [Errno 111] Connection refused.
Is adb running on your computer?
test@ubuntu:~/www/ANDROID$ adb devices
List of devices attached 
4d009a1a0ff93183    device

how can I solve this? Any suggestions?


Solution

  • Solved - I changed localhost back to 127.0.0.1 in hosts file and it solves an issue...