Thank you very much for your attention to my problem.!
System behavior is not stable today. Sometimes Chromium launches successfully, sometime not. Sometimes Chromium lanches, page opens!!!, but cant find element on the page! On my local machine the same code works correctly stable.
My code (an error can happen randomly on any line):
browser = await launch( )
page = await browser.newPage()
await page.goto('http://127.0.0.1/sampleimage/' + str(sampleId))
await page.type('#id_username', "screenshooter")
In 30% of cases error raised on the first line (on launch Chromium) with:
2020-08-30 11:50:11,457: Internal Server Error: /ajax/slacksend/
Traceback (most recent call last):
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/kostbash/gen_site/catalog/views.py", line 1607, in slack_send
slack.post_session(session_id)
File "/home/kostbash/gen_site/catalog/slack.py", line 366, in post_session
asyncio.run(sendSampleImage(
File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
return future.result()
File "/home/kostbash/gen_site/catalog/slack.py", line 115, in sendSampleImage
browser = await launch(
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/launcher.py", line 306, in launch
return await Launcher(options, **kwargs).launch()
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/launcher.py", line 167, in launch
self.browserWSEndpoint = get_ws_endpoint(self.url)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/launcher.py", line 226, in get_ws_endpoint
raise BrowserError('Browser closed unexpectedly:\n')
pyppeteer.errors.BrowserError: Browser closed unexpectedly:
**NO MATCH**
This error I described above the reason is urlopen("http://127.0.0.1:46574/json/version") work on my computer and rise [Errno 111] Connection refused on PythonAnywhere
in 10% of cases Chromium launched successfully but raise an error on second line (new page) with:
2020-08-30 11:46:29,764: [I:pyppeteer.launcher] Browser listening on: ws://127.0.0.1:37978/devtools/browser/acba2dab-5450-48c5-9eb8-000f50ebfffa
2020-08-30 11:46:29,768: !!!!!lanuched!!!!
2020-08-30 11:46:31,035: [I:pyppeteer.connection] connection closed
2020-08-30 11:46:31,303: Internal Server Error: /ajax/slacksend/
Traceback (most recent call last):
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/kostbash/gen_site/catalog/views.py", line 1607, in slack_send
slack.post_session(session_id)
File "/home/kostbash/gen_site/catalog/slack.py", line 366, in post_session
asyncio.run(sendSampleImage(
File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
return future.result()
File "/home/kostbash/gen_site/catalog/slack.py", line 122, in sendSampleImage
page = await browser.newPage()
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/browser.py", line 202, in newPage
return await self._defaultContext.newPage()
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/browser.py", line 355, in newPage
return await self._browser._createPageInContext(self._id)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/browser.py", line 216, in _createPageInContext
page = await target.page()
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/target.py", line 64, in page
new_page = await Page.create(
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/page.py", line 92, in create
await client.send('Page.enable'),
pyppeteer.errors.NetworkError: Protocol error Page.enable: Target closed.
in 40% of cases Chromium launch successfully, create new page, but raise an error on third line (open page) with:
2020-08-30 11:31:02,329: [I:pyppeteer.launcher] Browser listening on: ws://127.0.0.1:47045/devtools/browser/894128a5-3639-4851-92b8-fefcefd7a81a
2020-08-30 11:31:02,376: !!!!!lanuched!!!!
2020-08-30 11:31:03,419: Internal Server Error: /ajax/slacksend/
Traceback (most recent call last):
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/kostbash/gen_site/catalog/views.py", line 1607, in slack_send
slack.post_session(session_id)
File "/home/kostbash/gen_site/catalog/slack.py", line 366, in post_session
asyncio.run(sendSampleImage(
File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
return future.result()
File "/home/kostbash/gen_site/catalog/slack.py", line 123, in sendSampleImage
await page.goto('http://127.0.0.1:8000/sampleimage/' + str(sampleId))
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/page.py", line 879, in goto
raise PageError(result)
pyppeteer.errors.PageError: net::ERR_INVALID_HTTP_RESPONSE at http://127.0.0.1:8000/sampleimage/262993
and in 10% of cases Chromium launch successfully, create new page, open url, but raise an error on 4th line (find element on page) with:
2020-08-30 11:45:58,588: [I:pyppeteer.launcher] Browser listening on: ws://127.0.0.1:51167/devtools/browser/75e0ee66-a9e8-4693-a2f1-1b80750abbca
2020-08-30 11:45:58,592: !!!!!lanuched!!!!
2020-08-30 11:45:59,678: Internal Server Error: /ajax/slacksend/
Traceback (most recent call last):
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/kostbash/gen_site/catalog/views.py", line 1607, in slack_send
slack.post_session(session_id)
File "/home/kostbash/gen_site/catalog/slack.py", line 366, in post_session
asyncio.run(sendSampleImage(
File "/usr/lib/python3.8/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
return future.result()
File "/home/kostbash/gen_site/catalog/slack.py", line 124, in sendSampleImage
await page.type('#id_username', "screenshooter")
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/page.py", line 1589, in type
return await frame.type(selector, text, options, **kwargs)
File "/home/kostbash/.virtualenvs/venv1/lib/python3.8/site-packages/pyppeteer/frame_manager.py", line 660, in type
raise PageError('Cannot find {} on this page'.format(selector))
pyppeteer.errors.PageError: Cannot find #id_username on this page