New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty in Android Driver should allow connections from other interfaces apart from locahost #3022

Closed
lukeis opened this Issue Mar 3, 2016 · 7 comments

Comments

Projects
None yet
1 participant
@lukeis
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3022

What steps will reproduce the problem?
1. Install the Selenium Android driver application inside and android emulator
2. Start the application
3. Start a python test from the host's terminal and point to the android hub as a the
command executor using the example below

>>>from selenium import webdriver
>>>webdriver.Remote("http://localhost:8080/wd/hub", webdriver.DesiredCapabilities.ANDROID)
>>>driver.get("http://www.google.com")

The above code works as expected, it however fails  when you change  the second line
of code to
>>>webdriver.Remote("http://192.168.1.3:8080/wd/hub", webdriver.DesiredCapabilities.ANDROID)

with 192.168.1.3 being the IP address of the host and port 8080 forwarded from the
host to the android emulator. 

During an irc discussion in #selenium with D. Berrada, she suggested that changes be
made to http://code.google.com/p/selenium/source/browse/trunk/android/app/src/java/org/openqa/selenium/android/server/JettyService.java

Selenium Version: android-server.apk

Reported by mozbugs.retornam on 2011-12-07 22:37:39

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 3, 2016

Member
1. Install the Selenium Android driver application inside and android emulator
2. Start the application
3. Start a python test from the host's terminal and point to the android hub as a the
command executor using the example below

>>>from selenium import webdriver
>>>webdriver.Remote("http://localhost:8080/wd/hub", webdriver.DesiredCapabilities.ANDROID)
>>>driver.get("http://www.google.com")

The above code works as expected, it however fails  when you change  the second line
of code to
>>>webdriver.Remote("http://192.168.1.3:8080/wd/hub" , webdriver.DesiredCapabilities.ANDROID)

with 192.168.1.3 being the IP address of the host and port 8080 forwarded from the
host to the android emulator. 

During an irc discussion in #selenium with D. Berrada, she suggested that changes be
made to http://code.google.com/p/selenium/source/browse/trunk/android/app/src/java/org/openqa/selenium/android/server/JettyService.java

Selenium Version: android-server.apk

Reported by mozbugs.retornam on 2011-12-07 22:38:51

Member

lukeis commented Mar 3, 2016

1. Install the Selenium Android driver application inside and android emulator
2. Start the application
3. Start a python test from the host's terminal and point to the android hub as a the
command executor using the example below

>>>from selenium import webdriver
>>>webdriver.Remote("http://localhost:8080/wd/hub", webdriver.DesiredCapabilities.ANDROID)
>>>driver.get("http://www.google.com")

The above code works as expected, it however fails  when you change  the second line
of code to
>>>webdriver.Remote("http://192.168.1.3:8080/wd/hub" , webdriver.DesiredCapabilities.ANDROID)

with 192.168.1.3 being the IP address of the host and port 8080 forwarded from the
host to the android emulator. 

During an irc discussion in #selenium with D. Berrada, she suggested that changes be
made to http://code.google.com/p/selenium/source/browse/trunk/android/app/src/java/org/openqa/selenium/android/server/JettyService.java

Selenium Version: android-server.apk

Reported by mozbugs.retornam on 2011-12-07 22:38:51

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 3, 2016

Member

Reported by ajaykemparaj on 2011-12-08 03:02:08

  • Labels added: Component-WebDriver, Browser-Android
Member

lukeis commented Mar 3, 2016

Reported by ajaykemparaj on 2011-12-08 03:02:08

  • Labels added: Component-WebDriver, Browser-Android
@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 3, 2016

Member
It appears that Jetty should by default accept requests on all interfaces. I suspect
that the issue here is the adb port forwarding, which apparently binds to localhost.

Reported by dave.hunt on 2011-12-14 11:10:58

Member

lukeis commented Mar 3, 2016

It appears that Jetty should by default accept requests on all interfaces. I suspect
that the issue here is the adb port forwarding, which apparently binds to localhost.

Reported by dave.hunt on 2011-12-14 11:10:58

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 3, 2016

Member
Not quite. This is usually configured through /etc/jetty which I m not sure we have
on Android. The port forwarding barely forwards traffic from localhost:port to a port
of the emulator. That does not prevent connections from reaching locahost:port from
other machines.

Someone on the #jetty channel said that this could be set through the connectors we
use  .setHost(null) to enable listening on all interfaces (before starting the server).

I'll try it out and let you know if this works.

Reported by berrada@google.com on 2011-12-14 17:47:49

Member

lukeis commented Mar 3, 2016

Not quite. This is usually configured through /etc/jetty which I m not sure we have
on Android. The port forwarding barely forwards traffic from localhost:port to a port
of the emulator. That does not prevent connections from reaching locahost:port from
other machines.

Someone on the #jetty channel said that this could be set through the connectors we
use  .setHost(null) to enable listening on all interfaces (before starting the server).

I'll try it out and let you know if this works.

Reported by berrada@google.com on 2011-12-14 17:47:49

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 3, 2016

Member
@davehunt, you're right, adb forwards only binds to localhost.

Reported by berrada@google.com on 2011-12-14 18:07:23

Member

lukeis commented Mar 3, 2016

@davehunt, you're right, adb forwards only binds to localhost.

Reported by berrada@google.com on 2011-12-14 18:07:23

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 3, 2016

Member
Found a solution that works.

adb forward tcp:8080 tcp:8080

sudo apt-get install socat

socat TCP-LISTEN:8081,fork TCP:localhost:8080

Then you should be able to access the server from hostname:8081/wd/hub !

Reported by berrada@google.com on 2011-12-14 19:46:43

  • Status changed: Fixed
Member

lukeis commented Mar 3, 2016

Found a solution that works.

adb forward tcp:8080 tcp:8080

sudo apt-get install socat

socat TCP-LISTEN:8081,fork TCP:localhost:8080

Then you should be able to access the server from hostname:8081/wd/hub !

Reported by berrada@google.com on 2011-12-14 19:46:43

  • Status changed: Fixed
@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Mar 3, 2016

Member

Reported by luke.semerau on 2015-09-17 18:14:23

  • Labels added: Restrict-AddIssueComment-Commit
Member

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:14:23

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this Mar 3, 2016

@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.