Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out

这篇具有很好参考价值的文章主要介绍了Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题出现

主机调用异常:I/O error on POST request for "http://127.0.0.1:8181/api/xxxxxx/xxxxx": Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out

问题处理

出问题的代码

				ResponseEntity<String> response = dispatcherRestTemplate.postForEntity(url, rptResource.getParamJson(), String.class);

延长的读取时间文章来源地址https://www.toymoban.com/news/detail-774760.html

@Configuration
public class RestTemplateConfig {

	/**
	 * 调度器使用的RestTemplate,超时5s
	 * @return
	 */
	@Bean("dispatcherRestTemplate")
	public RestTemplate getRestTemplate(){
		RestTemplate restTemplate = new RestTemplateBuilder()
					.setConnectTimeout(200000)
					.setReadTimeout(200000)
					.build();
		//解决中文乱码
		List<HttpMessageConverter<?>> msgConv = restTemplate.getMessageConverters();
		if(msgConv != null && !msgConv.isEmpty()) {
			for(int i = 0; i < msgConv.size(); i++ ){
				if(msgConv.get(i).getClass().equals(StringHttpMessageConverter.class)) {
					msgConv.set(i, new StringHttpMessageConverter(StandardCharsets.UTF_8));
				}
			}
		}
		return restTemplate;
	}
}

到了这里,关于Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • nested exception is java.lang.NoClassDefFoundError

    出现这种问题,一般都是jar有问题,排查是哪个jar包,重新导入maven仓库一下就行了,有的时候需要把原来仓库里的包删掉,重新打包,有的时候要切换分支,到其他分支打包。 打包时候没有打进去,pom文件添加:

    2024年02月16日
    浏览(32)
  • 已解决 nested exception is java.lang.StackOverflowError

    已解决 nested exception is java.lang.StackOverflowError nested exception is java.lang.StackOverflowError 对于错误消息\\\"nested exception is java.lang.StackOverflowError\\\",通常表示程序递归调用过多,导致栈溢出。 下滑查看解决方法 下面是一些可能的解决方法: 检查递归方法:检查代码中是否存在无限递归

    2024年02月05日
    浏览(34)
  • nested exception is java.sql.SQLException: connection disabled

    在使用Spring Boot连接数据库时,有时候会遇到\\\"nested exception is java.sql.SQLException: connection disabled\\\"异常。这个异常通常是由以下原因引起的: 数据库连接配置错误:检查数据库连接的URL、用户名和密码是否正确配置。确保URL中包含正确的数据库名称,并且用户名和密码与数据库中

    2024年02月12日
    浏览(34)
  • 【已解决】Factory method ‘redisConnectionFactory‘ threw exception; nested exception is java.lang.

    Factory method ‘redisConnectionFactory’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/commons/pool2/impl/GenericObjectPoolConfig springboot整合redis报错 缺少对应依赖文件加上即可

    2024年02月06日
    浏览(38)
  • Handler dispatch failed; nested exception is java.lang.StackOverflowError

    错误原因代码:  检查发现在service层调用service,出现错误,因此改为调用mapper层即可。 更改后: 更改项目代码后,重新运行代码,即可正常运行。

    2024年02月09日
    浏览(43)
  • 已解决:Unexpected exception during bean creation; nested exception is java.lang.IllegalStateException:

    这个异常通常是由于在使用 Spring Cloud Feign 客户端进行负载均衡时缺少相关的依赖引起的。具体来说,它提示你忘记在项目的依赖中包含  spring-cloud-starter-loadbalancer 。 spring-cloud-starter-loadbalancer  是用于支持负载均衡功能的 Spring Cloud Starter 组件之一。它提供了负责将请求分发

    2024年02月08日
    浏览(34)
  • SpringBoot项目调用openCV报错:nested exception is java.lang.UnsatisfiedLinkError

    今天在通过web项目调用openCV的时候提示如下错误: 如下图所示: 但是通过直接启动java main函数确正常,初步诊断和SpringBoot热加载有关,遂将pom中如下配置注释掉: 重新启动web项目,异常排除。

    2024年01月16日
    浏览(59)
  • Handler dispatch failed; nested exception is java.lang.StackOverflowError 错误

    遇见内存溢出问题—jvm ` 提示:StackOverflowError栈内存溢出 StackOverflowError 是一个java中常出现的错误:在jvm运行时的数据区域中有一个java虚拟机栈,当执行java方法时会进行压栈弹栈的操作。在栈中会保存局部变量,操作数栈,方法出口等等。jvm规定了栈的最大深度,当执行时

    2024年02月15日
    浏览(47)
  • Redis exception; nested exception is io.lettuce.core.RedisException java.io.IOException 远程主机

    个人解决方法: 编辑/etc/ssh/sshd_config,添加配置项: 配置完后保存,重启服务: 以下是整个经过: 本地开发是发现隔一段时间没请求redis就会报错: 网上看了很多解决办法,都是timeout和tcp-keepalive的配置,多次试验后都无效,最奇怪的是putty链接服务器也是过一会就断开了,

    2024年02月12日
    浏览(29)
  • Maximum upload size exceeded; nested exception is java.lang.IllegalStateException解决办法

    一、问题描述 Springboot文件上传时报错:org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded; nested exception is java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.impl.FileSizeLimitExceededException: The field fileUrl exceeds its maximum permitted size of 10485760 bytes. 完整报错

    2024年02月11日
    浏览(30)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包