Skip to content
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

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 #1037

Open
ikarila opened this issue May 31, 2021 · 14 comments
Labels
bug Something isn't working priority: medium

Comments

@ikarila
Copy link

ikarila commented May 31, 2021

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.

@aaltat
Copy link
Member

aaltat commented Jun 1, 2021

Most likely you are experiencing same issue as in here: #599 (comment)

@ikarila
Copy link
Author

ikarila commented Jun 2, 2021

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.

@notKonU
Copy link

notKonU commented Jun 2, 2021

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:
grpc/grpc#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),))

@ikarila
Copy link
Author

ikarila commented Jun 2, 2021

Thx ! It worked :-)

@ikarila ikarila closed this as completed Jun 2, 2021
@mkorpela mkorpela reopened this Jun 3, 2021
@mkorpela
Copy link
Member

mkorpela commented Jun 3, 2021

We should implement @notKonU suggested change

@aaltat aaltat added bug Something isn't working priority: medium labels Jun 12, 2021
@mkorpela mkorpela added the HEL label Jan 13, 2022
@SNavgale
Copy link

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.

@frodo23g
Copy link

frodo23g commented Jan 13, 2023

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.

@Samiimov
Copy link

@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.

@Eli-Black-Work
Copy link

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)

@frodo23g
Copy link

frodo23g commented Mar 24, 2023

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
Copy link

frodo23g commented May 9, 2023

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.

@simonmeggle
Copy link
Contributor

(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.

@aaltat
Copy link
Member

aaltat commented Jan 26, 2024

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.

@simonmeggle
Copy link
Contributor

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!

@aaltat aaltat removed the HEL label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: medium
Projects
None yet
Development

No branches or pull requests

9 participants