![](/img/trans.png)
[英]Connection refused error in bitbucket pipeline with Docker library
[英]Playwright error connection refused in docker
我正在尝试以无头模式在playwright._impl._api_types.Error: net::ERR_CONNECTION_REFUSED at http://app/
运行 end-2-end 测试,并playwright._impl._api_types.Error: net::ERR_CONNECTION_REFUSED at http://app/
获取playwright._impl._api_types.Error: net::ERR_CONNECTION_REFUSED at http://app/
。 它只发生在铬和火狐。 Webkit 可以工作,但在查找选择器方面也存在问题。 当我从本地主机运行它们时,E2E 测试通过了。 当我从本地主机发出请求时,请求成功。 当我从 e2e-tests 容器制作 curl 时,请求也成功。
docker-compose.yml :
app:
image: ${APP}
ports:
- 8090:80
environment:
SERVICE_HOST: ${REAL_IP}:8080
KEYCLOAK_URL: 'http://keycloak:8080'
DOLLAR: $$
restart: unless-stopped
command: sh -c "envsubst < /etc/nginx/conf.d/proxy.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
depends_on:
backend:
condition: service_healthy
e2e-tests:
build: ../../auto_tests/end2end
environment:
SERVICE_HOST: 'http://app:80'
HEADLESS_MODE: 1
SERVICE_LOG_LEVEL: DEBUG
depends_on:
- app
铬:
============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0 -- /usr/bin/python3
=================================== FAILURES ===================================
__________________________ TestAuth.test_correct_auth __________________________
tests/test_auth.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fixture/session.py:10: in login
self.app.navigation.open_home_page()
fixture/navigation.py:15: in open_home_page
page.goto(SERVICE_HOST)
/usr/local/lib/python3.8/dist-packages/playwright/sync_api/_generated.py:7133: in goto
self._sync(
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_sync_base.py:111: in _sync
return task.result()
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_page.py:467: in goto
return await self._main_frame.goto(**locals_to_params(locals()))
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_frame.py:119: in goto
await self._channel.send("goto", locals_to_params(locals()))
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_connection.py:39: in send
return await self.inner_send(method, params, False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <playwright._impl._connection.Channel object at 0x7fa7a814bca0>
method = 'goto', params = {'url': 'http://app:80'}, return_as_dict = False
async def inner_send(
self, method: str, params: Optional[Dict], return_as_dict: bool
) -> Any:
if params is None:
params = {}
callback = self._connection._send_message_to_server(self._guid, method, params)
done, pending = await asyncio.wait(
{self._connection._transport.on_error_future, callback.future},
return_when=asyncio.FIRST_COMPLETED,
)
if not callback.future.done():
callback.future.cancel()
> result = next(iter(done)).result()
E playwright._impl._api_types.Error: net::ERR_CONNECTION_REFUSED at http://app/
E =========================== logs ===========================
E navigating to "http://app/", waiting until "load"
E ============================================================
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_connection.py:57: Error
火狐:
=================================== FAILURES ===================================
tests/test_auth.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fixture/session.py:10: in login
self.app.navigation.open_home_page()
fixture/navigation.py:15: in open_home_page
page.goto(SERVICE_HOST)
/usr/local/lib/python3.8/dist-packages/playwright/sync_api/_generated.py:7133: in goto
self._sync(
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_sync_base.py:111: in _sync
return task.result()
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_page.py:467: in goto
return await self._main_frame.goto(**locals_to_params(locals()))
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_frame.py:119: in goto
await self._channel.send("goto", locals_to_params(locals()))
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_connection.py:39: in send
return await self.inner_send(method, params, False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <playwright._impl._connection.Channel object at 0x7f89aa274ca0>
method = 'goto', params = {'url': 'http://app:80'}, return_as_dict = False
async def inner_send(
self, method: str, params: Optional[Dict], return_as_dict: bool
) -> Any:
if params is None:
params = {}
callback = self._connection._send_message_to_server(self._guid, method, params)
done, pending = await asyncio.wait(
{self._connection._transport.on_error_future, callback.future},
return_when=asyncio.FIRST_COMPLETED,
)
if not callback.future.done():
callback.future.cancel()
> result = next(iter(done)).result()
E playwright._impl._api_types.Error: NS_ERROR_CONNECTION_REFUSED
E =========================== logs ===========================
E navigating to "http://app/", waiting until "load"
E ============================================================
网络套件:
=================================== FAILURES ===================================
tests/test_auth.py:6:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fixture/session.py:27: in login
page.click('#username')
/usr/local/lib/python3.8/dist-packages/playwright/sync_api/_generated.py:7813: in click
self._sync(
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_sync_base.py:111: in _sync
return task.result()
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_page.py:624: in click
return await self._main_frame.click(**locals_to_params(locals()))
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_frame.py:448: in click
await self._channel.send("click", locals_to_params(locals()))
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_connection.py:39: in send
return await self.inner_send(method, params, False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <playwright._impl._connection.Channel object at 0x7f5669d6aca0>
method = 'click', params = {'selector': '#username'}, return_as_dict = False
async def inner_send(
self, method: str, params: Optional[Dict], return_as_dict: bool
) -> Any:
if params is None:
params = {}
callback = self._connection._send_message_to_server(self._guid, method, params)
done, pending = await asyncio.wait(
{self._connection._transport.on_error_future, callback.future},
return_when=asyncio.FIRST_COMPLETED,
)
if not callback.future.done():
callback.future.cancel()
> result = next(iter(done)).result()
E playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
E =========================== logs ===========================
E waiting for selector "#username"
E ============================================================
/usr/local/lib/python3.8/dist-packages/playwright/_impl/_connection.py:57: TimeoutError
我解决了我的问题。 事实上,我的 docker 容器(前端)被称为“app”,它也是前端应用程序的域名。 我的应用程序在 http 上本地运行。 Chromium 和 geko 驱动程序强制某些域名的 http S连接,其中之一是“app”。 所以我必须更改包含前端应用程序的 docker 容器的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.