《Bug 系列》Server returned HTTP response code: 423 for URL

news/2024/11/29 9:34:27/

前言

这个异常在网上的资料非常少,说明一般情况下,不会出现这个异常,都由操作系统、网络协议栈封装好了,开发者对此无感知。

现在出现了这个异常,一个非常可能的原因:开发者自己在其中做了某些处理。

异常堆栈

2023-02-23 20:35:09.415 4f263114c30044f28726ce8cc2464f44 http-nio-8080-exec-9 ERROR 
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://xxx/xxx": Server returned HTTP response code: 423 for URL: http://xxx/xxx; nested exception is java.io.IOException: Server returned HTTP response code: 423 for URL: http://xxx/xxxat org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:785)at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:711)at org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:437)at sun.reflect.GeneratedMethodAccessor173.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)at javax.servlet.http.HttpServlet.service(HttpServlet.java:665)at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:769)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Server returned HTTP response code: 423 for URL: http://cjy-backend.retailo2o.com/linklong-server-model/commonDomain/queryCommonDomainByConditionat sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)at org.springframework.http.client.SimpleClientHttpResponse.getBody(SimpleClientHttpResponse.java:89)at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:93)at org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:77)at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:66)at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:776)... 104 common frames omitted

分析

HTTP status code 423 的含义:资源锁定。

可能是响应经过网关时,网关解析响应的字节流失败:

Caused by: java.io.IOException: Server returned HTTP response code: 423 for URL: http://xxx/yyy/zzzat sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)

网关是前后端的通信的桥梁。
我们的项目访问公网域名,走了公司自己的网关;可能网关在处理公网流量时,做了某些处理,响应数据中的的某些字符触发了这个错误。

解决方案

不再访问公网域名,直接访问内部域名。
暂时未复现这个异常,再观察一段时间。


http://www.ppmy.cn/news/841650.html

相关文章

423D

题意:给出n个点,其中k个点只能有一条边相连,剩下的边至少有2条边相连,问构造出的树最远的两个点最近是多少 解答:度为1的点的数目越多,这个距离就越小。那么构造一个中心点,发散地连k个点。不够…

LeetCode 423. 从英文中重建数字

题目链接: 力扣https://leetcode-cn.com/problems/reconstruct-original-digits-from-english/ class Solution:def originalDigits(self, s: str) -> str:from collections import Counterc Counter(s)cnt [0] * 10cnt[0] c["z"]cnt[2] c["…

leetcode 423. Reconstruct Original Digits from English | 423. 从英文中重建数字(Java)

题目 https://leetcode.com/problems/reconstruct-original-digits-from-english/ 题解 class Solution {public String originalDigits(String s) {int[] total new int[26];for (int i 0; i < s.length(); i) {total[s.charAt(i) - a];}int[] num new int[10];// 0:…

423C

题意&#xff1a;告诉你一些字符串的信息&#xff0c;要求你重组并输出字典序最小的这个字符串&#xff0c;告诉你的信息是&#xff0c;某个子串在某几个位置出现&#xff0c;保证给的信息不冲突 解答&#xff1a;暴力&#xff01;但是&#xff01;要注意重复地位置要跳过&a…

TortoiseSVN提交提示423 Locked的解决办法

首先选择要提交的文件右键菜单&#xff1a;“TortoiseSVN->get locks”在对话框的左下角有个steal the locks选项&#xff0c;勾选这个选项&#xff0c;你就可以窃取别人的锁。然后你就成为锁的拥有者&#xff0c;然后commit提交即可。commit之后&#xff0c;点击TortoiseSV…

423,动态规划和递归解最小路径和

想了解更多数据结构以及算法题&#xff0c;可以关注微信公众号“数据结构和算法”&#xff0c;每天一题为你精彩解答。也可以扫描下面的二维码关注 给定一个包含非负整数的 m x n 网格&#xff0c;请找出一条从左上角到右下角的路径&#xff0c;使得路径上的数字总和为最小。…

LLM - Baichuan7B Tokenizer 生成训练数据

目录 一.引言 二.Tokenizer 原始数据 1.原始数据样例 2.加载并 Token 原始数据 2.1 参数准备 2.2 单条样本处理逻辑 2.3 批量处理逻辑 2.4 主函数与完整代码 三.shell 执行 四.总结 一.引言 前面提到了自己在微调 Baichuan7B Lora 的过程中遇到了一些问题&#xff0c…

刷题记录01

题目一. 这道题要先解释一下什么是非递增,非递增就是a[i] >a[i1],递增则是相反. 非递减就是a[i]>a[i1],递减就是相反 大方向思路是: 遍历数组判断相邻元素的顺序关系统计排序子序列数量 具体思路: 本题依次比较整个数组a[i1]>a[i] &#xff0c;则进入非递增序列判…