写短信验证功能点击发送验证码,前台写的ajax.then..catch,弹出了一个请求状态504,后台zuulexception
504错误代表网关超时,是指服务器作为网关或代理,没有及时从上游服务器接收到请求
正常情况下,是由于被请求服务器发送超时引起。
解决方法:只需在网关的配置里面,负载均衡超时等待时间
原来yml配置文件
#端口号
server:
port: 10010
#服务名
spring:
application:
name: cgzuul
servlet:
multipart:
max-file-size: 2MB #上传文件的大小
#将网关服务添加到注册中心
eureka:
client:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: http://127.0.0.1:10086/eureka
instance:
prefer-ip-address: true
#网关统一配置 -- 访问路径 http://localhost:10010/v3/服务名/路径
zuul:
prefix: /v3
sensitive-headers: Cookie,Set-Cookie
新增ribbon配置
#端口号
server:
port: 10010
#服务名
spring:
application:
name: cgzuul
servlet:
multipart:
max-file-size: 2MB #上传文件的大小
#将网关服务添加到注册中心
eureka:
client:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: http://127.0.0.1:10086/eureka
instance:
prefer-ip-address: true
#网关统一配置 -- 访问路径 http://localhost:10010/v3/服务名/路径
zuul:
prefix: /v3
sensitive-headers: Cookie,Set-Cookie
#解决504方案
ribbon:
ReadTimeout: 120000 #请求处理的超时时间
ConnectTimeout: 30000 #请求连接的超时时间