shimh-develop / blog-vue-springboot

基于Vue+SpringBoot构建的博客项目
1.93k stars 552 forks source link

你好,我想问一下报连接超时是哪里出问题了? #5

Open wenlou opened 5 years ago

wenlou commented 5 years ago

也不能注册,一注册就报这个错误。 ERROR com.shimh.common.controlleradvice.GlobalExceptionHandler 88 ExceptionHandler - 服务器内部错误 , uri: /users/currentUser , caused by: java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)

image

CxcPDF commented 5 years ago

超时就是我上一个issue中提到的问题

wenlou commented 5 years ago

超时就是我上一个issue中提到的问题

改成你提的

//请求的参数 Object[] args = joinPoint.getArgs(); if(args.length>0) { String params = JSON.toJSONString(args[0]); log.setParams(params); } 依然不行,不能注册,一刷新就疯狂的报连接超时

CxcPDF commented 5 years ago

个人感觉应该是前端代码有问题,导致了前端不断地向后端发送请求。具体的错误在哪还得作者来告诉我们

CxcPDF commented 5 years ago
   //请求的参数
    Object[] arguments = joinPoint.getArgs();
    Object[] args = new Object[arguments.length];
    for (int i = 0; i < arguments.length; i++) {
        if (arguments[i] instanceof ServletRequest || arguments[i] instanceof ServletResponse || arguments[i] instanceof MultipartFile) {
            //ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false)
            //ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response
            continue;
        }
        args[i] = arguments[i];
    }
    if(args.length>0) {
        String params = JSON.toJSONString(args[0]);
        log.setParams(params);
    }

把代码改成这样就行了,因为参数里面有HttpRequest的东西,这个是不能被序列化的,所以就会报错

CxcPDF commented 5 years ago

超时就是我上一个issue中提到的问题

改成你提的

//请求的参数 Object[] args = joinPoint.getArgs(); if(args.length>0) { String params = JSON.toJSONString(args[0]); log.setParams(params); } 依然不行,不能注册,一刷新就疯狂的报连接超时

//请求的参数 Object[] arguments = joinPoint.getArgs(); Object[] args = new Object[arguments.length]; for (int i = 0; i < arguments.length; i++) { if (arguments[i] instanceof ServletRequest || arguments[i] instanceof ServletResponse || arguments[i] instanceof MultipartFile) { //ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false) //ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response continue; } args[i] = arguments[i]; } if(args.length>0) { String params = JSON.toJSONString(args[0]); log.setParams(params); } 把代码改成这样就行了,因为参数里面有HttpRequest的东西,这个是不能被序列化的,所以就会报错

shimh-develop commented 5 years ago

超时就是我上一个issue中提到的问题

改成你提的 //请求的参数 Object[] args = joinPoint.getArgs(); if(args.length>0) { String params = JSON.toJSONString(args[0]); log.setParams(params); } 依然不行,不能注册,一刷新就疯狂的报连接超时

//请求的参数 Object[] arguments = joinPoint.getArgs(); Object[] args = new Object[arguments.length]; for (int i = 0; i < arguments.length; i++) { if (arguments[i] instanceof ServletRequest || arguments[i] instanceof ServletResponse || arguments[i] instanceof MultipartFile) { //ServletRequest不能序列化,从入参里排除,否则报异常:java.lang.IllegalStateException: It is illegal to call this method if the current request is not in asynchronous mode (i.e. isAsyncStarted() returns false) //ServletResponse不能序列化 从入参里排除,否则报异常:java.lang.IllegalStateException: getOutputStream() has already been called for this response continue; } args[i] = arguments[i]; } if(args.length>0) { String params = JSON.toJSONString(args[0]); log.setParams(params); } 把代码改成这样就行了,因为参数里面有HttpRequest的东西,这个是不能被序列化的,所以就会报错

是 写日志时带上访问的参数,这里没有细看,可以注释掉或改一下逻辑

gl01108023 commented 5 years ago

屏蔽掉了还是报连接超时

shimh-develop commented 5 years ago

屏蔽掉了还是报连接超时 @gl01108023 可以跟下代码 找下具体问题

Viserion-nlper commented 3 years ago

我也是这个错误 能解决一下吗

meteorOSS commented 1 year ago

我也出现这个错误了,看了一下是因为默认导入的数据里文章的userid是1,而不存在1这个user。注册一个账号,把文章表里的user_id字段改成你刚注册的就行了