You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
3.4 KiB
125 lines
3.4 KiB
# 常见问题
|
|
|
|
## Connection has been closed BEFORE send operation
|
|
|
|
压测时出现`Connection has been closed BEFORE send operation`,`java.nio.channels.ClosedChannelException`之类的错误
|
|
|
|
- 解决办法
|
|
|
|
尝试调大内存分配1G或2G,`-Xms1g -Xmx1g`
|
|
|
|
## spring cloud gateway [DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144]
|
|
|
|
如果POST请求body内容太大可能会报这个错误
|
|
|
|
- 解决版办法
|
|
|
|
网关指定配置`spring.codec.max-in-memory-size=xx`,xx默认是262144,即256K(262144=256*1024)
|
|
|
|
## primordials is not defined
|
|
|
|
node版本太高导致与gulp版本不兼容,解决方法:node退回11版本。参考https://blog.csdn.net/zxxzxx23/article/details/103000393
|
|
|
|
## Nacos指定group
|
|
|
|
可在配置文件中添加:`spring.cloud.nacos.discovery.group=xxx`指定group,不加默认是:DEFAULT_GROUP
|
|
|
|
## 在SpringCloudGateway中获取请求参数
|
|
|
|
```java
|
|
ApiParam apiParam = ServerWebExchangeUtil.getApiParam(exchange);
|
|
```
|
|
|
|
## 微服务端如何获取appId等参数
|
|
|
|
```java
|
|
OpenContext openContext = ServiceContext.getCurrentContext().getOpenContext();
|
|
System.out.println("app_id:" + openContext.getAppId());
|
|
System.out.println("token:" + openContext.getAppAuthToken());
|
|
```
|
|
|
|
|
|
## 如何关闭签名验证
|
|
|
|
- 针对某一个接口关闭签名验证
|
|
`@Open(value = "alipay.story.get", ignoreValidate = true)`
|
|
|
|
|
|
## 注册到eureka显示hostname,非ip
|
|
|
|
```properties
|
|
eureka.instance.prefer-ip-address=true
|
|
eureka.instance.instance-id=${spring.cloud.client.ip-address}:${server.port}
|
|
```
|
|
|
|
```xml
|
|
<dependency>
|
|
<groupId>org.springframework.cloud</groupId>
|
|
<artifactId>spring-cloud-commons</artifactId>
|
|
</dependency>
|
|
```
|
|
|
|
参考:https://www.jianshu.com/p/5ad8317961b7
|
|
|
|
## 直接访问服务的swagger-ui.html ,提示access forbidden
|
|
|
|
找到微服务的`OpenServiceConfig.java`,重写内部类Swagger2中的swaggerAccessProtected()方法,返回false。线上请设置成true
|
|
|
|
```java
|
|
// 开启文档
|
|
@Configuration
|
|
@EnableSwagger2
|
|
public static class Swagger2 extends SwaggerSupport {
|
|
@Override
|
|
protected String getDocTitle() {
|
|
return "故事API";
|
|
}
|
|
|
|
@Override
|
|
protected boolean swaggerAccessProtected() {
|
|
return false;
|
|
}
|
|
}
|
|
```
|
|
|
|
## 调试网关出现服务不可用
|
|
|
|
打断点调试,网关出现Read Timeout
|
|
|
|
参考:https://blog.csdn.net/qq_36872046/article/details/81058045
|
|
|
|
yml添加:
|
|
|
|
```properties
|
|
# https://blog.csdn.net/qq_36872046/article/details/81058045
|
|
# 路由转发超时时间,毫秒,默认值1000,详见:RibbonClientConfiguration.DEFAULT_READ_TIMEOUT。
|
|
# 如果微服务端 处理时间过长,会导致ribbon read超时,解决办法将这个值调大一点
|
|
ribbon.ReadTimeout= 60000
|
|
```
|
|
|
|
|
|
## 其它微服务没有开放接口,需要排除
|
|
|
|
在sop-gateway项目中配置
|
|
|
|
```properties
|
|
# 排除服务,多个用,隔开
|
|
sop.service.exclude=your-serviceId1,your-serviceId2
|
|
```
|
|
|
|
或者使用正则:
|
|
|
|
```properties
|
|
# 排除以"test-"开头的
|
|
# 多个正则用英文分号(;)隔开
|
|
sop.service.exclude-regex=test\\-.*
|
|
```
|
|
|
|
## ISV公私钥 & 平台公私钥
|
|
|
|
```java
|
|
ISV私钥(必须):ISV保存,用来生成签名 --> ISV公钥(必须):平台保存,用来校验签名是否正确
|
|
平台私钥(非必须):平台保存,对返回结果生成签名 --> 平台公钥(非必须):ISV保存,用来校验签名是否正确
|
|
```
|
|
|
|
总结:私钥负责加密生成签名,公钥负责校验签名是否正确
|
|
|