Can we run our test scripts if the appium server and the mobile device are only connected via USB?

Hi,

Currently I am running my test scripts where the appium server and mobile device are on the same WiFi network.

But when the appium server and the mobile device are on a different WiFi network / not connected to WiFi but only connected via USB i get the below error when I try to my scripts.

Exception in thread “main” org.openqa.selenium.remote.UnreachableBrowserException: Could not start a newsession. Possible causes are invalid address of the remote server or browser start-up failure.

Build info: version: ‘unknown’, revision: ‘unknown’, time: ‘unknown’

System info: host: ‘admin-PC’, ip:‘127.0.0.1’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’,
java.version: ‘1.8.0_45’

Driver info: driver.version:AndroidDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:593)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:109)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:39)
at MFKPackage1.MFKSmartPhone1.initializeApp(MFKSmartPhone1.java:76)
at MFKPackage1.MFKSmartPhone1.main(MFKSmartPhone1.java:302)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:136)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:152)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:270)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:140)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:57)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:260)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:161)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:153)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:271)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:254)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:126)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:72)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:133)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:572)

8 more

Is it necessary that both appium server and the mobile device to be on the same WiFi network? Cannot we run our test scripts via USB?

@rohansurya, we run our tests with devices that are on different WiFi’s than the appium server.

I wish I had something more helpful than debug steps (which you likely have already done). I would do the following:

  1. Verify the server can see the device through adb (adb devcies)
  2. Check if appium still works when the device is on the same WiFi
  3. Verify no other changes were made when the device is on a different WiFi than the server
  4. Check your code that is trying to connect to the device – are you using some static value which would be different on the other WiFi.
1 Like

@willosser…i tried different scenarios and found out that the appium server (laptop) need to be on a network
(connected to some network, i.e. either WiFi / LAN / hotspot, etc.) at any point in time else we get “getaddrinfo ENOENT” error.

My issue is resolved now. Thank You!!

Hi Rohan,

It’ll be great if you can assist me on this issue you faced where you wanted to connect with android devices on different networks via appium.

I am trying to do the same but to no avail!

1 Like

Hi, were you able to find a solution? I seem to have the same problem.