首页 > 解决方案 > Python Selenium program terminates after 2~3 hours since it started. It seems like WebSocket Connection Problem. Please teach me

问题描述

I am making an automation program using Python Selenium.

The program should be operated 24hours a day.

But whenever I started the program, after 2 hours and 30min, it automatically terminates.

I don't know what the problem is.

But I saw the web socker error presented on 'Chrome Driver Console' and 'Webpage Development Tool Console'.

Please look at the attached image.

How can I fix this?

enter image description here

标签: pythonseleniumwebsocketterminatehandshake

解决方案


任何以 5XX 开头的错误代码都表示服务器错误,在您的情况下,您会收到 502 和 504 错误,简而言之,可以总结如下。

502/504 错误通常表明计算机,即您收到 504 消息的网站无法控制但依赖的计算机,与它的通信速度不够快。

这很可能是硒反应不够引起的。硒的最大运行时间为 1800 秒(30 分钟),但可以更改caps['max_duration'] = Integer为更长的测试时间。

我认为的最高值是 14400 秒(4 小时),这大致表明了您收到错误的原因。我的建议是每 2.30 小时重新开始一次测试。


推荐阅读