0

I need to use the remote proxy server for my test, but proxy required login and password for authorization. I try to use BrowserMobProxyServer for this:

BrowserMobProxy bmp = new BrowserMobProxyServer();
bmp.start();
// This inject my remote proxy ip:port and login password.
bmp.autoAuthorization("111.111.111.111:8000", "l0gVal", "pasVal", AuthType.BASIC);

Proxy proxy = ClientUtil.createSeleniumProxy(bmp);
// I guess if info about this proxy already injected it should work without loin & password form but auth alert whenever appear( 
proxy.setHttpProxy("111.111.111.111:8000");
proxy.setSslProxy("111.111.111.111:8000");
ChromeOptions options = new ChromeOptions();
options.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new ChromeDriver(options);

driver.get("https://whoer.net");

Help me understand my mistake, I sure it's possible, but how. I get this exception:

tarting ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef) on port 30000 Only local connections are allowed. 2018-04-26 11:45:22 ERROR o.l.p.impl.ClientToProxyConnection - (AWAITING_INITIAL) at net.lightbody.bmp.util.BrowserMobHttpUtil.removeMatchingPort(BrowserMobHttpUtil.java:274) ~[browsermob-core-2.1.0-beta-6.jar:na] at net.lightbody.bmp.filters.HttpsHostCaptureFilter.clientToProxyRequest(HttpsHostCaptureFilter.java:36) ~[browsermob-core-littleproxy-2.1.0-beta-6.jar:na] at net.lightbody.bmp.filters.BrowserMobHttpFilterChain.clientToProxyRequest(BrowserMobHttpFilterChain.java:65) ~[browsermob-core-littleproxy-2.1.0-beta-6.jar:na] at org.littleshoot.proxy.impl.ClientToProxyConnection.doReadHTTPInitial(ClientToProxyConnection.java:227) ~[littleproxy-1.1.0-beta-bmp-12.jar:na] at org.littleshoot.proxy.impl.ClientToProxyConnection.readHTTPInitial(ClientToProxyConnection.java:191) ~[littleproxy-1.1.0-beta-bmp-12.jar:na] at org.littleshoot.proxy.impl.ClientToProxyConnection.readHTTPInitial(ClientToProxyConnection.java:80) ~[littleproxy-1.1.0-beta-bmp-12.jar:na] at org.littleshoot.proxy.impl.ProxyConnection.readHTTP(ProxyConnection.java:135) ~[littleproxy-1.1.0-beta-bmp-12.jar:na] at org.littleshoot.proxy.impl.ProxyConnection.read(ProxyConnection.java:120) ~[littleproxy-1.1.0-beta-bmp-12.jar:na] at org.littleshoot.proxy.impl.ProxyConnection.channelRead0(ProxyConnection.java:587) ~[littleproxy-1.1.0-beta-bmp-12.jar:na] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) ~[netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-all-4.0.36.Final.jar:4.0.36.Final] at org.littleshoot.proxy.impl.ProxyConnection$RequestReadMonitor.channelRead(ProxyConnection.java:715) [littleproxy-1.1.0-beta-bmp-12.jar:na] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:277) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:264) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-all-4.0.36.Final.jar:4.0.36.Final] at org.littleshoot.proxy.impl.ProxyConnection$BytesReadMonitor.channelRead(ProxyConnection.java:692) [littleproxy-1.1.0-beta-bmp-12.jar:na] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:962) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:485) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:399) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371) [netty-all-4.0.36.Final.jar:4.0.36.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [netty-all-4.0.36.Final.jar:4.0.36.Final] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101] Apr 26, 2018 11:45:23 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS

Pavel
  • 1,436
  • 3
  • 19
  • 39

2 Answers2

1

"on port 30000 Only local connections are allowed"

seems to me that the proxy is refusing connection

check the proxy configuation or use another port

pburgr
  • 943
  • 1
  • 5
  • 17
  • but port I got from the proxy provider. 111.111.111.111:`8000` I can't specify this parameter. Or you mean something else? – Pavel May 11 '18 at 16:04
  • "on port 30000" means, that comunication try go through port 30000. Maybe you can't event reach the proxy server. – pburgr May 14 '18 at 06:21
1

Another idea is using custum browser profile; similar as described in Automatically download pdf in firefox gecko driver using selenium java. Didn't tried Chrome yet. At least you can exclude cause in your code.

pburgr
  • 943
  • 1
  • 5
  • 17