当前位置: 首页 > news >正文

聊聊tomcat的connection-timeout

本文主要研究一下tomcat的connection-timeout

ServerProperties.Tomcat

org/springframework/boot/autoconfigure/web/ServerProperties.java

	public static class Tomcat {/*** Access log configuration.*/private final Accesslog accesslog = new Accesslog();/*** Thread related configuration.*/private final Threads threads = new Threads();/*** Tomcat base directory. If not specified, a temporary directory is used.*/private File basedir;/*** Delay between the invocation of backgroundProcess methods. If a duration suffix* is not specified, seconds will be used.*/@DurationUnit(ChronoUnit.SECONDS)private Duration backgroundProcessorDelay = Duration.ofSeconds(10);/*** Maximum size of the form content in any HTTP post request.*/private DataSize maxHttpFormPostSize = DataSize.ofMegabytes(2);/*** Maximum amount of request body to swallow.*/private DataSize maxSwallowSize = DataSize.ofMegabytes(2);/*** Whether requests to the context root should be redirected by appending a / to* the path. When using SSL terminated at a proxy, this property should be set to* false.*/private Boolean redirectContextRoot = true;/*** Whether HTTP 1.1 and later location headers generated by a call to sendRedirect* will use relative or absolute redirects.*/private boolean useRelativeRedirects;/*** Character encoding to use to decode the URI.*/private Charset uriEncoding = StandardCharsets.UTF_8;/*** Maximum number of connections that the server accepts and processes at any* given time. Once the limit has been reached, the operating system may still* accept connections based on the "acceptCount" property.*/private int maxConnections = 8192;/*** Maximum queue length for incoming connection requests when all possible request* processing threads are in use.*/private int acceptCount = 100;/*** Maximum number of idle processors that will be retained in the cache and reused* with a subsequent request. When set to -1 the cache will be unlimited with a* theoretical maximum size equal to the maximum number of connections.*/private int processorCache = 200;/*** Comma-separated list of additional patterns that match jars to ignore for TLD* scanning. The special '?' and '*' characters can be used in the pattern to* match one and only one character and zero or more characters respectively.*/private List<String> additionalTldSkipPatterns = new ArrayList<>();/*** Comma-separated list of additional unencoded characters that should be allowed* in URI paths. Only "< > [ \ ] ^ ` { | }" are allowed.*/private List<Character> relaxedPathChars = new ArrayList<>();/*** Comma-separated list of additional unencoded characters that should be allowed* in URI query strings. Only "< > [ \ ] ^ ` { | }" are allowed.*/private List<Character> relaxedQueryChars = new ArrayList<>();/*** Amount of time the connector will wait, after accepting a connection, for the* request URI line to be presented.*/private Duration connectionTimeout;/*** Static resource configuration.*/private final Resource resource = new Resource();/*** Modeler MBean Registry configuration.*/private final Mbeanregistry mbeanregistry = new Mbeanregistry();/*** Remote Ip Valve configuration.*/private final Remoteip remoteip = new Remoteip();//......}	

springboot的ServerProperties.Tomcat定义了connectionTimeout属性,用于指定接受连接之后等待uri的时间

customizeConnectionTimeout

org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java

	private void customizeConnectionTimeout(ConfigurableTomcatWebServerFactory factory, Duration connectionTimeout) {factory.addConnectorCustomizers((connector) -> {ProtocolHandler handler = connector.getProtocolHandler();if (handler instanceof AbstractProtocol) {AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;protocol.setConnectionTimeout((int) connectionTimeout.toMillis());}});}

customizeConnectionTimeout将connectionTimeout写入到AbstractProtocol

AbstractProtocol

org/apache/coyote/AbstractProtocol.java

    public void setConnectionTimeout(int timeout) {endpoint.setConnectionTimeout(timeout);}

AbstractProtocol将timeout设置到endpoint

AbstractEndpoint

org/apache/tomcat/util/net/AbstractEndpoint.java

	public void setConnectionTimeout(int soTimeout) { socketProperties.setSoTimeout(soTimeout); }/*** Keepalive timeout, if not set the soTimeout is used.*/private Integer keepAliveTimeout = null;public int getKeepAliveTimeout() {if (keepAliveTimeout == null) {return getConnectionTimeout();} else {return keepAliveTimeout.intValue();}}

AbstractEndpoint将timeout设置到socketProperties的soTimeout,另外它的getKeepAliveTimeout方法在keepAliveTimeout为null的时候,使用的是getConnectionTimeout

Http11Processor

org/apache/coyote/http11/Http11Processor.java

    public SocketState service(SocketWrapperBase<?> socketWrapper)throws IOException {RequestInfo rp = request.getRequestProcessor();rp.setStage(org.apache.coyote.Constants.STAGE_PARSE);// Setting up the I/OsetSocketWrapper(socketWrapper);// FlagskeepAlive = true;openSocket = false;readComplete = true;boolean keptAlive = false;SendfileState sendfileState = SendfileState.DONE;while (!getErrorState().isError() && keepAlive && !isAsync() && upgradeToken == null &&sendfileState == SendfileState.DONE && !protocol.isPaused()) {// Parsing the request headertry {if (!inputBuffer.parseRequestLine(keptAlive, protocol.getConnectionTimeout(),protocol.getKeepAliveTimeout())) {if (inputBuffer.getParsingRequestLinePhase() == -1) {return SocketState.UPGRADING;} else if (handleIncompleteRequestLineRead()) {break;}}//......}//......}//......}          

Http11Processor的service方法在执行inputBuffer.parseRequestLine时传入了keptAlive、protocol.getConnectionTimeout()、protocol.getKeepAliveTimeout()参数

小结

springboot提供了tomcat的connection-timeout参数配置,其配置的是socket timeout,不过springboot没有提供对keepAliveTimeout的配置,它默认是null,读取的是connection timeout的配置。

相关文章:

聊聊tomcat的connection-timeout

序 本文主要研究一下tomcat的connection-timeout ServerProperties.Tomcat org/springframework/boot/autoconfigure/web/ServerProperties.java public static class Tomcat {/*** Access log configuration.*/private final Accesslog accesslog new Accesslog();/*** Th…...

HCIA-RS基础:动态路由协议基础

摘要&#xff1a;本文介绍动态路由协议的基本概念&#xff0c;为后续动态路由协议原理课程提供基础和引入。主要讲解常见的动态路由协议、动态路由协议的分类&#xff0c;以及路由协议的功能和自治系统的概念。文章旨在优化标题吸引力&#xff0c;并通过详细的内容夯实读者对动…...

jQuery 第十一章(表单验证插件推荐)

文章目录 前言jValidateZebra FormjQuery.validValValidityValidForm BuilderForm ValidatorProgressionformvalidationjQuery Validation PluginjQuery Validation EnginejQuery ValidateValidarium后言 前言 hello world欢迎来到前端的新世界 &#x1f61c;当前文章系列专栏&…...

SSL握手失败的解决方案

一、SSL握手失败的原因&#xff1a; 1&#xff0c;证书过期&#xff1a;SSL证书有一个有效期限&#xff0c;如果证书过期&#xff0c;就会导致SSL握手失败。 2&#xff0c;证书不被信任&#xff1a;如果网站的SSL证书不被浏览器或操作系统信任&#xff0c;也会导致SSL握手失败…...

K8S客户端一 Rancher的安装

一 安装方式一 通过官网方式安装&#xff1a;官网 sudo docker run --privileged -d --restartunless-stopped -p 80:80 -p 443:443 rancher/rancher:stable访问服务器地址即可&#xff1a;http://192.168.52.128 修改语言 第一次安装会生成密码&#xff0c;查看密码步骤如下…...

websocket与node.js实现

什么是 websocket&#xff1f; websoket 是一种网络通信协议&#xff0c;基于 tcp 连接的全双工通信协议&#xff08;客户端和服务器可以同时收发信息&#xff09;&#xff0c;值得注意的是他不基于 http 协议&#xff0c;websocket 只有在建立连接的时候使用到 http 协议进行…...

postpresql 查询某张表的字段名和字段类型

postpresql 查询某张表的字段名和字段类型 工作中第一次接触postpresql&#xff0c;接触到这么个需求&#xff0c;只是对sql有点了解&#xff0c;于是就网上查阅资料。得知通过系统表可以查询&#xff0c;设计到几张系统表&#xff1a;pg_class、pg_attrubute、information_sc…...

jetson NX部署Yolov8

一,事情起因,由于需要对无人机机载识别算法进行更新,所以需要对yolov8算法进行部署到边缘端。 二,环境安装 安装虚拟环境管理工具,这个根据个人喜好。 我们需要选择能够在ARM架构上运行的conda,这里我们选择conda-forge 下载地址 安装即可 剩下的就是和conda 创建虚拟…...

【论文阅读笔记】Emu Edit: Precise Image Editing via Recognition and Generation Tasks

【论文阅读笔记】Emu Edit: Precise Image Editing via Recognition and Generation Tasks 论文阅读笔记论文信息摘要背景方法结果额外 关键发现作者动机相关工作1. 使用输入和编辑图像的对齐和详细描述来执行特定的编辑2. 另一类图像编辑模型采用输入掩码作为附加输入 。3. 为…...

python:列表的拷贝详解

python&#xff1a;列表的拷贝详解 文章目录 python&#xff1a;列表的拷贝详解方法1&#xff1a;直接赋值&#xff08;&#xff09;方法2&#xff1a;浅拷贝&#xff08;.copy方法&#xff09;格式原理注意 方法3&#xff1a;深拷贝&#xff08;.deepcopy方法&#xff09;格式…...

zip4j压缩使用总结

一、引入依赖 <dependency><groupId>net.lingala.zip4j</groupId><artifactId>zip4j</artifactId><version>1.3.1</version></dependency>二、使用添加文件&#xff08;addFiles&#xff09;的方式生成压缩包 /*** Author wan…...

【第一部分:概述】ARM Realm Management Monitor specification

目录 概述机密计算系统软件组成MonitorRealmRealm Management Monitor (RMM)Virtual Machine (VM)HypervisorSecure Partition Manager (SPM)Trusted OS (TOS)Trusted Application (TA) Realm Management Monitor 参考文献 概述 RMM是一个软件组件&#xff0c;它构成了实现ARM…...

切换服务器上自己用户目录下的 conda 环境和一个外部的 Conda 环境

如果我们有自己的 Miniconda 安装和一个外部的 Conda 环境&#xff08;比如一个全局安装的 Anaconda&#xff09;&#xff0c;我们可以通过修改 shell 环境来切换使用它们。这通常涉及到更改 PATH 环境变量&#xff0c;以便指向你想要使用的 Conda 安装的可执行文件&#xff1a…...

移动端的自动化基于类实现启动一次应用跑全部用例

1.unittest框架 class TestStringMethods(unittest.TestCase): def setUp(self) -> None: # 每一条测试用例开始前执行 print("setup") def tearDown(self) -> None: # 每一条测试用例结束后执行 print("teardown") …...

Python与设计模式--抽象工厂模式

Python与设计模式–抽象工厂模式 一、快餐点餐系统 想必大家一定见过类似于麦当劳自助点餐台一类的点餐系统吧。在一个大的触摸显示屏上&#xff0c;有三类可以选择的上餐品&#xff1a;汉堡等主餐、小食、饮料。当我们选择好自己需要的食物&#xff0c;支付完成后&#xff0…...

JSP:MVC

一个好的Web应用&#xff1a; 功能完善、易于实现和维护易于扩展等的体系结构 一个Web应用通常分为两个部分&#xff1a; 1. 由界面设计人员完成的表示层&#xff08;主要做网页界面设计&#xff09; 2. 由程序设计人员实现的行为层&#xff08;主要完成本Web应用的各种功能…...

微服务-京东秒杀

1 项目介绍 技术栈 后端 SpringCloud 中Netflix 五大组件&#xff1a; EurekaRibbonHystrixOpenfeignZuul SpringBootSpringSpringMVCMyBatis 数据库 MySQLRedis 前端 html5cssjsjQuery 消息中间件 RabbitMQ 2 项目搭建 项目分析 后端 shop-parent [pom] &#xff08;商…...

「MACOS限定」 如何将文件上传到GitHub仓库

介绍 本期讲解&#xff1a;如何在苹果电脑上上传文件到github远程仓库 注&#xff1a;写的很详细 方便我的朋友可以看懂操作步骤 第一步 在电脑上创建一个新目录&#xff08;文件夹&#xff09; 注&#xff1a;创建GitHub账号、新建github仓库、git下载的步骤这里就不过多赘…...

python opencv 边缘检测(sobel、沙尔算子、拉普拉斯算子、Canny)

python opencv 边缘检测&#xff08;sobel、沙尔算子、拉普拉斯算子、Canny&#xff09; 这次实验&#xff0c;我们分别使用opencv 的 sobel算子、沙尔算子、拉普拉斯算子三种算子取进行边缘检测&#xff0c;然后后面又使用了Canny算法进行边缘检测。 直接看代码&#xff0c;代…...

【Unity入门】鼠标输入和键盘输入

Unity的Input类提供了许多监听用户输入的方法&#xff0c;比如我们常见的鼠标&#xff0c;键盘&#xff0c;手柄等。我们可以用Input类的接口来获取用户的输入信息 一、监听鼠标输入 GetMouseButtonUp 、GetMouseButtonDown、GetMouseButton input.GetMouseButtonDown和 inp…...

XUnity Auto Translator:Unity游戏实时翻译完全指南

XUnity Auto Translator&#xff1a;Unity游戏实时翻译完全指南 【免费下载链接】XUnity.AutoTranslator 项目地址: https://gitcode.com/gh_mirrors/xu/XUnity.AutoTranslator XUnity Auto Translator是一款功能强大的Unity游戏本地化工具&#xff0c;能够实时翻译游戏…...

如何突破Intel CPU性能瓶颈:智能电压调节工具的终极指南

如何突破Intel CPU性能瓶颈&#xff1a;智能电压调节工具的终极指南 【免费下载链接】Universal-x86-Tuning-Utility Unlock the full potential of your Intel/AMD based device. 项目地址: https://gitcode.com/gh_mirrors/un/Universal-x86-Tuning-Utility 你是否曾被…...

CustomTkinter:解决Python GUI现代化渲染与跨平台适配的技术架构

CustomTkinter&#xff1a;解决Python GUI现代化渲染与跨平台适配的技术架构 【免费下载链接】CustomTkinter A modern and customizable python UI-library based on Tkinter 项目地址: https://gitcode.com/gh_mirrors/cu/CustomTkinter Python的Tkinter框架在桌面GUI…...

别再傻傻分不清了!QA、QE、QC到底谁负责啥?一张图帮你理清软件测试岗位分工

软件测试岗位全解析&#xff1a;QA、QE、QC的核心差异与职业选择 刚踏入软件测试领域的新人&#xff0c;面对QA、QE、QC这些缩写时&#xff0c;往往会感到一头雾水。这些看似相似的岗位名称背后&#xff0c;其实隐藏着完全不同的职责边界和发展路径。记得我刚开始接触这个领域时…...

别再手动找Bug了!用Fortify SCA给你的Java项目做个“安全体检”(附完整扫描流程)

告别低效排雷&#xff1a;用Fortify SCA为Java代码打造自动化安全防线 凌晨三点的办公室&#xff0c;咖啡杯早已见底&#xff0c;屏幕上的SQL注入漏洞却像捉迷藏般难以定位——这场景对Java开发者来说再熟悉不过。传统人工代码审查不仅消耗团队50%以上的迭代周期&#xff0c;更…...

从零到可视化:手把手教你用RocketMQ Console在Windows上搭建消息队列监控面板

从零到可视化&#xff1a;手把手教你用RocketMQ Console在Windows上搭建消息队列监控面板 在分布式系统架构中&#xff0c;消息队列作为解耦和异步通信的核心组件&#xff0c;其运行状态的实时监控至关重要。RocketMQ Console作为官方提供的可视化工具&#xff0c;能将晦涩的命…...

从智能窗户到海水淡化:拆解《Solar Energy Materials and Solar Cells》里的那些“跨界”太阳能技术

太阳能技术的跨界革命&#xff1a;从建筑节能到淡水获取的创新路径 清晨的阳光透过智能窗户自动调节室内亮度&#xff0c;海水在太阳能装置中悄然转化为清洁淡水——这些看似科幻的场景&#xff0c;正通过材料科学的突破逐步成为现实。在能源转型的全球背景下&#xff0c;太阳能…...

SAP BAPI_GOODSMVT_CREATE领料报错?手把手教你排查‘短缺未限制使用的SL’(附完整ABAP代码)

SAP BAPI_GOODSMVT_CREATE领料报错深度排查指南&#xff1a;从"短缺未限制使用的SL"到完整解决方案 当你在深夜的生产支持中突然收到"短缺未限制使用的SL"报错时&#xff0c;那种熟悉的焦虑感又回来了。这个看似简单的错误信息背后&#xff0c;往往隐藏着S…...

Spring Boot 与 MyBatis 性能优化

Spring Boot 与 MyBatis 性能优化实战 在当今快速迭代的互联网应用中&#xff0c;性能优化是提升系统稳定性和用户体验的关键。Spring Boot 作为轻量级框架&#xff0c;与 MyBatis 这一灵活高效的 ORM 工具结合&#xff0c;已成为 Java 开发的主流选择。随着数据量增长和业务复…...

ATK-LORA-01模块实战:从环境监测到智能农场,一个模块搞定5公里无线数据传输

ATK-LORA-01模块实战&#xff1a;从环境监测到智能农场&#xff0c;一个模块搞定5公里无线数据传输 在物联网技术快速发展的今天&#xff0c;远距离、低功耗的无线通信解决方案成为许多项目的核心需求。ATK-LORA-01模块凭借其出色的LoRa技术特性&#xff0c;为开发者提供了一种…...