Open jianleiyu opened 2 hours ago
handshake failed; returned -1, SSL error code 1, net_error -100 可以增加参数 --ignore-certificate-errors 和 --ignore-ssl-errors 在LaunchOptions的args属性里设置, 这是我在搜索的一篇文章 https://cloud.tencent.com/developer/ask/sof/1622767 网上的很多关于 linux上启动chrome的文章都可以用来解决jvppeteer启动chrome所遇到的问题
--ignore-certificate-errors 和 --ignore-ssl-errors这两个参数无效,已经在新版本移除了,使用现象是刚开始启动没有报错,也可以使用,但是一段时间后就会有报错
--user-data-dir = "xxxxx",应该配置上明确的路径。
更新一下依赖 debian apt install -y ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
或者 centos yum install -y alsa-lib.x86_64 atk.x86_64 cups-libs.x86_64 gtk3.x86_64 ipa-gothic-fonts libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXrandr.x86_64 libXScrnSaver.x86_64 libXtst.x86_64 pango.x86_64 xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-fonts-cyrillic xorg-x11-fonts-misc xorg-x11-fonts-Type1 xorg-x11-utils
C:\Users\fanyong\Desktop\jvppeteer\example.local-browser\win32-127.0.6533.99\chrome-win32\chrome.exe --allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-hang-monitor --disable-infobars --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-search-engine-choice-screen --disable-sync --enable-automation --export-tagged-pdf --generate-pdf-document-outline --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold,IsolateSandboxedIframes --enable-features=PdfOopif about:blank --user-data-dir=C:\Users\fanyong\AppData\Local\Temp\jvppeteer_dev_chrome_profile-2907967499320729211 --remote-debugging-port=0
启动参数配置成自己的值,进行启动
启动方式如下:google-chrome --no-sandbox --user-data-dir --headless --remote-debugging-port=9222 使用代码如下: browser = Puppeteer.connect("http://localhost:9222"); Page page = browser.newPage(); GoToOptions goToOptions = new GoToOptions(); goToOptions.setWaitUntil(Collections.singletonList(PuppeteerLifeCycle.NETWORKIDLE)); log.info("开始请求页面 URL{} ", url); page.goTo(url, goToOptions); PDFOptions pdfOptions = new PDFOptions(); pdfOptions.setPath("/Users/Desktop/baidu.pdf"); pdfOptions.setOutline(true);//生成大纲 pdfOptions.setFormat(PaperFormats.a4);//A4大小 pdfOptions.setPrintBackground(true);//打印背景图形,百度一下这个蓝色按钮就显示出来了 pdfOptions.setPreferCSSPageSize(false); pdfOptions.setScale(1.1);//缩放比例1.1 page.pdf(pdfOptions);
浏览器报错信息如下: DevTools listening on ws://127.0.0.1:9222/devtools/browser/93cc72ae-eb61-48f5-be86-41e728d06ad7 Warning: /usr/lib64/libvulkan_intel_hasvk.so: undefined symbol: wl_proxy_marshal_flags Warning: loader_icd_scan: Failed loading library associated with ICD JSON /usr/lib64/libvulkan_intel_hasvk.so. Ignoring this JSON Warning: /usr/lib64/libvulkan_intel.so: undefined symbol: wl_proxy_marshal_flags Warning: loader_icd_scan: Failed loading library associated with ICD JSON /usr/lib64/libvulkan_intel.so. Ignoring this JSON Warning: /usr/lib64/libvulkan_lvp.so: undefined symbol: wl_proxy_marshal_flags Warning: loader_icd_scan: Failed loading library associated with ICD JSON /usr/lib64/libvulkan_lvp.so. Ignoring this JSON Warning: /usr/lib64/libvulkan_radeon.so: undefined symbol: wl_proxy_marshal_flags Warning: loader_icd_scan: Failed loading library associated with ICD JSON /usr/lib64/libvulkan_radeon.so. Ignoring this JSON Warning: vkCreateInstance: Found no drivers! Warning: vkCreateInstance failed with VK_ERROR_INCOMPATIBLE_DRIVER at CheckVkSuccessImpl (../../third_party/dawn/src/dawn/native/vulkan/VulkanError.cpp:106)
Warning: /usr/lib64/libvulkan_intel_hasvk.so: undefined symbol: wl_proxy_marshal_flags Warning: loader_icd_scan: Failed loading library associated with ICD JSON /usr/lib64/libvulkan_intel_hasvk.so. Ignoring this JSON Warning: /usr/lib64/libvulkan_intel.so: undefined symbol: wl_proxy_marshal_flags Warning: loader_icd_scan: Failed loading library associated with ICD JSON /usr/lib64/libvulkan_intel.so. Ignoring this JSON Warning: /usr/lib64/libvulkan_lvp.so: undefined symbol: wl_proxy_marshal_flags Warning: loader_icd_scan: Failed loading library associated with ICD JSON /usr/lib64/libvulkan_lvp.so. Ignoring this JSON Warning: /usr/lib64/libvulkan_radeon.so: undefined symbol: wl_proxy_marshal_flags Warning: loader_icd_scan: Failed loading library associated with ICD JSON /usr/lib64/libvulkan_radeon.so. Ignoring this JSON Warning: vkCreateInstance: Found no drivers! Warning: vkCreateInstance failed with VK_ERROR_INCOMPATIBLE_DRIVER at CheckVkSuccessImpl (../../third_party/dawn/src/dawn/native/vulkan/VulkanError.cpp:106)
[869622:869639:1029/093631.200245:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -101 [869622:869639:1029/093703.966168:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -101 [869585:869632:1029/094633.305858:ERROR:http_server.cc(466)] Cannot handle request with protocol: HTTP/1.0 [869585:869632:1029/094633.430773:ERROR:http_server.cc(466)] Cannot handle request with protocol: HTTP/1.0 [869622:869639:1029/094729.643494:ERROR:ssl_client_socket_impl.cc(878)] handshake failed; returned -1, SSL error code 1, net_error -101 [869621:869621:1029/095759.792028:ERROR:gles2_cmd_decoder_passthrough.cc(1053)] [GroupMarkerNotSet(crbug.com/242999)!:A0701D007C150000]Automatic fallback to software WebGL has been deprecated. Please use the --enable-unsafe-swiftshader flag to opt in to lower security guarantees for trusted content. [869622:869639:1029/100022.823451:ERROR:socket_manager.cc(147)] Failed to resolve address for stun.services.mozilla.com., errorcode: -105 [869622:869639:1029/100022.823550:ERROR:socket_manager.cc(147)] Failed to resolve address for stun.services.mozilla.com., errorcode: -105 [869621:869621:1029/100023.250471:ERROR:gles2_cmd_decoder_passthrough.cc(1053)] [GroupMarkerNotSet(crbug.com/242999)!:A0D01D007C150000]Automatic fallback to software WebGL has been deprecated. Please use the --enable-unsafe-swiftshader flag to opt in to lower security guarantees for trusted content. [869585:869585:1029/210242.038275:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.039492:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.051964:ERROR:network_service_instance_impl.cc(613)] Network service crashed, restarting service. [869585:869585:1029/210242.063111:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.072758:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.073672:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.075490:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.076407:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.077194:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.078051:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.080437:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.081306:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.083448:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.084327:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.086100:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.086832:ERROR:zygote_communication_linux.cc(297)] Failed to send GetTerminationStatus message to zygote [869585:869585:1029/210242.129112:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002 [869585:869585:1029/210242.131061:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002 [869585:869585:1029/210242.132082:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002 [869585:869585:1029/210242.133214:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002