简体   繁体   English

实施Spring Boot Security时管道破损

[英]Broken pipe when implementing Spring Boot Security

I have a Spring Boot MVC application that was working fine. 我有一个运行良好的Spring Boot MVC应用程序。

I'm trying to follow a number of tutorials on integrating Spring Security to handle user login, however as soon as I create the following class, the application starts generating a Broken pipe error. 我正在尝试遵循有关集成Spring Security来处理用户登录的许多教程,但是,一旦我创建了以下类,应用程序就会开始生成Broken pipe错误。

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .antMatchers("/","/home").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginPage("/login")
                .permitAll()
                .and()
                .logout()
                .permitAll();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth
                .inMemoryAuthentication()
                .withUser("user").password("password").roles("USER");
    }
}

I've tried a number of different tutorials thinking that maybe the original tutorial had some errors, but it's still happening. 我尝试了许多不同的教程,以为原始教程可能有一些错误,但仍在发生。

2015-11-25 09:39:57.593  INFO 64614 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2015-11-25 09:39:57.620  INFO 64614 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 27 ms
2015-11-25 09:39:58.970 ERROR 64614 --- [nio-8080-exec-2] o.s.boot.context.web.ErrorPageFilter     : Cannot forward to error page for request [/login] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false

org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe

I can't figure out what's causing this. 我不知道是什么原因造成的。

I'm deploying this application on a local Tomcat instance. 我正在将此应用程序部署在本地Tomcat实例上。

To confirm, the application still appears to be working ok, I'm not sure if this error is something I need to worry about? 为了确认,该应用程序似乎仍然可以正常运行,我不确定是否需要担心此错误?

I have the same error, but I think this kind of error can depend of lot of things. 我有同样的错误,但是我认为这种错误可能取决于很多因素。 Me too I use spring-boot with angularJs stack. 我也使用带有springJs堆栈的spring-boot。

I have the same issue when I try to wait the answer of the request (who take time) to my spring-boot application. 当我尝试等待对我的spring-boot应用程序的请求(花费时间)的回答时,我遇到了相同的问题。

I put my solution here if it's can help someone: 如果可以帮助某人,我将解决方案放在这里:

For me, the problem come from Apache Httpd configuration, because I put my application behind apache server. 对我来说,问题出在Apache Httpd配置上,因为我将应用程序置于apache服务器之后。 And in my case, apache close the connexion when it's exceed the default timeout (300 seconds I think). 就我而言,当超过默认超时时间(我认为是300秒)时,apache将关闭连接。 When this happens your spring-boot display broken pipe error. 发生这种情况时,spring-boot会显示broken pipe错误。

To fix this problem you just need to add TimeOut yourValueInSecond in the httpd.conf of your apache httpd configuration file. 要解决此问题,您只需要在apache httpd配置文件的httpd.conf中添加TimeOut yourValueInSecond

Before to change your configuration file test if it's really due to the apache httpd server by sending the request directly on your tomcat server. 在更改配置文件之前,通过直接在tomcat服务器上发送请求来测试它是否真的是由于apache httpd服务器引起的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM