I have my Express js connect to multiple dbs. Which works everytime I startup my app. But As soon as my connection to my database goes stale... the connection returns an error code of PROTOCOL_CONNECTION_LOST. Which is normal for a mysql when a connection is idle. My mysql server is deployed in AWS RDS which also works just fine.
问题是,每次我的 express 应用程序遇到PROTOCOL_CONNECTION_LOST错误时,它都应该重新连接到数据库,这实际上也有效。BUUT 当我尝试对我的 MYSQL 数据库进行查询时。它返回一个Error: Cannot enqueue Query after fatal error.错误。我一直在处理这个问题,我的解决方法是每次都重新启动 express 应用程序。希望其他人遇到过这种情况并可以提供建议。
这是我连接到数据库的示例代码:
var …Run Code Online (Sandbox Code Playgroud) 我正在对网站进行爬行,并且使用 scrapy 中的 LinkExtractor 来爬行链接并确定其响应状态。
此外,我还想使用链接提取器从网站获取图像源。我有一个代码,它与网站网址配合得很好,但我似乎无法获取图像。因为它不会登录控制台。
handle_httpstatus_list = [404,502]
# allowed_domains = [''mydomain']
start_urls = ['somedomain.com/']
http_user = '###'
http_pass = '#####'
rules = (
Rule(LinkExtractor(allow=('domain.com',),canonicalize = True, unique = True), process_links='filter_links', follow = False, callback='parse_local_link'),
Rule(LinkExtractor(allow=('cdn.domain.com'),tags = ('img',),attrs=('src',),canonicalize = True, unique = True), follow = False, callback='parse_image_link'),
)
def filter_links(self,links):
for link in
def parse_local_link(self, response):
if response.status != 200:
item = LinkcheckerItem()
item['url'] = response.url
item['status'] = response.status
item['link_type'] = 'local'
item['referer'] = response.request.headers.get('Referer',None)
yield item
def parse_image_link(self, …Run Code Online (Sandbox Code Playgroud)