@wenshao 您好,想跟你请教个问题:
web项目停一段时间再访问会报错:
Caused by: java.net.SocketException: Connection reset by peer: socket write error
报了错,再访问就正常了。
我怀疑是validationQuery根本没有定时执行,我检查配置都没问题,这块有什么特殊配置?
项目使用的是 spring注入+jdbctemplate.
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init"
destroy-method="close">
<property name="url" value="**" />
<property name="username" value="**" />
<property name="password" value="**" />
<property name="filters" value="stat" />
<property name="maxActive" value="100" />
<property name="initialSize" value="1" />
<property name="maxWait" value="60000" />
<property name="minIdle" value="1" />
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<property name="minEvictableIdleTimeMillis" value="300000" />
<property name="validationQuery" value="SELECT 'x' FROM DUAL" />
<property name="validationQueryTimeout" value="30000" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="poolPreparedStatements" value="true" />
<property name="maxPoolPreparedStatementPerConnectionSize" value="50" />
</bean>
能把堆栈信息提供出来么?谢谢,看我的补充<preclass="brush:java;toolbar:true;auto-links:false;">[16:15:03][http--8080-16]ERROR[com.alibaba.druid.util.JdbcUtils:84]-closeconnectionerrorjava.sql.SQLRecoverableException:IO错误:Connectionresetbypeer:socketwriteerroratoracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:770)atoracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:4581)atcom.alibaba.druid.filter.FilterChainImpl.connection_close(FilterChainImpl.java:169)atcom.alibaba.druid.filter.stat.StatFilter.connection_close(StatFilter.java:254)atcom.alibaba.druid.filter.FilterChainImpl.connection_close(FilterChainImpl.java:165)atcom.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.close(ConnectionProxyImpl.java:115)atcom.alibaba.druid.util.JdbcUtils.close(JdbcUtils.java:82)atcom.alibaba.druid.pool.DruidDataSource.discardConnection(DruidDataSource.java:969)atcom.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:936)atcom.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544)atcom.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:661)atcom.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540)atcom.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:882)atcom.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:874)atcom.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:97)atorg.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)atorg.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)atorg.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:388)atorg.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:468)atorg.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:478)atorg.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:488)atorg.springframework.jdbc.core.JdbcTemplate.queryForObject(JdbcTemplate.java:494)atcom.test.web.db.JdbcBase.count(JdbcBase.java:553)atcom.test.web.dao.privilege.RoleDao.getRoleList(RoleDao.java:88)atcom.test.web.controller.privilege.RoleController.role_list(RoleController.java:44)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)atorg.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)atorg.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)atorg.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)atorg.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)atorg.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)atorg.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)atorg.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)atorg.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:114)atorg.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:91)atcom.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)atorg.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)atorg.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)atcom.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)atcom.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)atcom.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)atcom.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:270)atcom.caucho.server.port.TcpConnection.run(TcpConnection.java:678)atcom.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721)atcom.caucho.util.ThreadPool$Item.run(ThreadPool.java:643)atjava.lang.Thread.run(UnknownSource)Causedby:java.net.SocketException:Connectionresetbypeer:socketwriteerroratjava.net.SocketOutputStream.socketWrite0(NativeMethod)atjava.net.SocketOutputStream.socketWrite(UnknownSource)atjava.net.SocketOutputStream.write(UnknownSource)atoracle.net.ns.DataPacket.send(DataPacket.java:209)atoracle.net.ns.NetOutputStream.flush(NetOutputStream.java:215)atoracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:302)atoracle.net.ns.NetInputStream.read(NetInputStream.java:249)atoracle.net.ns.NetInputStream.read(NetInputStream.java:171)atoracle.net.ns.NetInputStream.read(NetInputStream.java:89)atoracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:123)atoracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:79)atoracle.jdbc.driver.T4CMAREngineStream.unmarshalUB1(T4CMAREngineStream.java:426)atoracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:390)atoracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)atoracle.jdbc.driver.T4C7Ocommoncall.doOLOGOFF(T4C7Ocommoncall.java:59)atoracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:757)...52more
好像大家都是Oracle连接的时候出问题,Mysql连接的时候却没有问题,我也遇到这个问题了,按理来说设置了validationQuery应该可以解决的,时间上并没有什么卵用~打算换个连接池试试了。
可以看下这个<atarget="_blank"rel="nofollow">https://github.com/alibaba/druid/issues/591
这个后来有找到解决方案嘛?
回复<aclass="referer"target="_blank">@Andyfoo:您那边使用的也是Oracle吗现在用的新版没有问题找到一个解决方案,可以试试
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。