robotframework-browser icon indicating copy to clipboard operation
robotframework-browser copied to clipboard

Playwright process connection in container fails when proxy is set .. client_channel/lb_policy/pick_first/pick_first.cc","file_line":397,"grpc_status":14

Open ikarila opened this issue 3 years ago • 14 comments

When running test in a container - and when there are proxy-settings in the environment - Browser systematically fails to connect with Playwright. Test passes in host with proxies set

export http_proxy http://proxy-xxxx:8080 export https_proxy http://proxy-xxxxxxx:8080

The following keep repeating in the trace:

<_InactiveRpcError of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "failed to connect to all addresses" debug_error_string = "{"created":"@1622469263.764339400","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":5419,"referenced_errors":[{"created":"@1622469263.764108500","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":397,"grpc_status":14}]}" >

If env proxy settings are removed, Browser connects to Playwright and test proceeds, but in absence of proxy test cannot connect URL and thus fails by Playwright timeout.

Doing these for npm does not help to get thru.. npm config set proxy xxxx npm config set https-proxy xxxx

To Reproduce Steps to reproduce the behavior:

  1. Run prebuilt marketsquare/robotframework-browser container image docker run -it -v ${pwd}:/home/jenkins/tests:rw -v ${pwd}/report:/home/jenkins/report:rw marketsquare/robotframework-browser /bin/bash

  2. Proxy settings are added to env (This is required in the domain host is running) export https_proxy=http://proxy-xxxxx:8080 export http_proxy=http://proxy-xxxxx:8080

  3. Simple test is launched by robot -L TRACE test.robot

<test.robot> *** Settings *** Library Browser

*** Test Cases *** Starting a browser with a page New Browser chromium headless=true New Context viewport={‘width’: 1920, ‘height’: 1080} New Page https://marketsquare.github.io/robotframework-browser/Browser.html Get Title == Browser

  1. See error root@e2794c33c434:/home/jenkins/tests# robot -L DEBUG test.robot ============================================================================== Test ============================================================================== [ ERROR ] Calling method '_start_suite' of listener 'Browser' failed: Could not connect to the playwright process at port 45797. [ ERROR ] Calling method '_start_test' of listener 'Browser' failed: Could not connect to the playwright process at port 57861. Starting a browser with a page | FAIL |

Expected behavior Expect client_channel to connect even if there is a proxy setting in the environment

** version information ** pwuser@4de0d08e255c:/home/jenkins/tests$ pip list |grep robot robotframework 4.0.1 robotframework-assertion-engine 0.0.6 robotframework-browser 5.0.0 robotframework-pythonlibcore 2.2.1

pwuser@4de0d08e255c:/home/jenkins/tests$ npm --version 6.14.12 pwuser@4de0d08e255c:/home/jenkins/tests$ npm list |grep grp +-- @grpc/[email protected] +-- [email protected]

pwuser@4de0d08e255c:/home/jenkins/tests$ pip list |grep grpcio grpcio 1.37.1 grpcio-tools 1.37.1

Additional context Add any other context about the problem here.

ikarila avatar May 31 '21 14:05 ikarila

Most likely you are experiencing same issue as in here: https://github.com/MarketSquare/robotframework-browser/issues/599#issuecomment-762946870

aaltat avatar Jun 01 '21 20:06 aaltat

This case host where docker is running indeed enforces proxy, it is required for outside connections. However, I have not found a way to make it work with Browser. "@599... grpc seems to use this proxy even for localhost. Explicitly unsetting http(s)_proxy solved the problem for me..". Even though there is env setting "no_proxy=no_proxy=.nnn.com,0.0.0.0,127.0.0.1,.nnnn.local" I guess gprc-connection in container probably omits it. I'd need a solution with proxy set and containerized RF/Browser connecting successfully.

ikarila avatar Jun 02 '21 07:06 ikarila

Your no_proxy environment variable should include localhost. If there's nothing else on that list, then export no_proxy=localhost should do the trick.

gRPC has had some issues recognizing the no_proxy variable, but that should be fixed: https://github.com/grpc/grpc/issues/9989

Modifying playwright.py on lines 108 & 125 should also have the same effect: grpc.insecure_channel(f"localhost:{self.port}") -> grpc.insecure_channel(f"localhost:{self.port}", options=(("grpc.enable_http_proxy", 0),))

notKonU avatar Jun 02 '21 13:06 notKonU

Thx ! It worked :-)

ikarila avatar Jun 02 '21 13:06 ikarila

We should implement @notKonU suggested change

mkorpela avatar Jun 03 '21 06:06 mkorpela

Just checking if this is now implemented of workaround suggested above export no_proxy=localhost is required? This was working fine till recently for me.

SNavgale avatar Nov 24 '22 16:11 SNavgale

I have the same issue as discribed here in my builded Docker image. It apeared after I used the Version

  • robotframework-browser 14.2.1
  • robotframework 6.0.1 With Version robotframework-browser 14.1.0 it is all good with set "ENV http_proxy/https_proxy" in my Docker File.

With robotframework-browser 15.0.0 the Problem is still there. I tried "no_proxy=localhost" with no luck.

frodo23g avatar Jan 13 '23 07:01 frodo23g

@frodo23g @SNavgale Spent quite a while researching this just to find out that my node and npm version were too old for functioning rfbrowser requirements 😅 Setting and unsetting env variables didn't work for me either.

Samiimov avatar Jan 20 '23 11:01 Samiimov

Interestingly, I needed to do export no_proxy=localhost,127.0.0.1 instead of just export no_proxy=localhost.

(Or rather, ps $env:NO_PROXY='localhost,127.0.0.1', since we're using PowerShell)

Eli-Black-Work avatar Mar 23 '23 06:03 Eli-Black-Work

I tried your Suggestion with "127.0.0.1", but no change. I Still get error: [ ERROR ] Calling method '_start_suite' of listener 'Browser' failed: Could not connect to the playwright process at port 53493. 08:55:12  E0324 08:55:12.977517693 7 hpack_parser.cc:1218] Error parsing metadata: error=invalid value key=content-type value=text/html; charset=utf-8 08:55:13  E0324 08:55:13.129892355 7 hpack_parser.cc:1218] Error parsing metadata: error=invalid value key=content-type value=text/html; charset=utf-8 08:55:28  [ ERROR ] Calling method '_start_test' of listener 'Browser' failed: Could not connect to the playwright process at port 53493.

frodo23g avatar Mar 24 '23 08:03 frodo23g

I have Tried the Suggestion with the latest Version 16.1.0.. Now it is working on my Container with active Proxy. I build my Image with ENV no_proxy='127.0.0.1,localhost'. I use for my execution with jenkins an ".sh" File. In the File I doesn't set any "http_proxy" or "no_proxy" Variable with Export. I hope, that helps others.

frodo23g avatar May 09 '23 14:05 frodo23g

(Blowing away the dust 💨) An chance that Browserlibrary does not use a proxy at all to communicate with the Playwright process? Setting no_proxy env var works but is not ideal from a user perspective.

simonmeggle avatar Jan 25 '24 11:01 simonmeggle

I don’t recall any changes in this matter. But I have not looked deeply on the gRPC side, would it offer easy solution for this. Perhaps there is an flag when we setup the services that could be used.

aaltat avatar Jan 26 '24 15:01 aaltat

I also asked Robocorp to allow no_proxy var in RCC environments: https://github.com/robocorp/rcc/issues/57 But anyway, it would be great if this could be fixed inside the library. Thanks!

simonmeggle avatar Jan 26 '24 15:01 simonmeggle