Comments (12)
我确认一下,concept-websocket-loadbalance-spring-boot-starter是集成在业务服务中不是集成在网关中
有没有更详细的信息,比如服务的配置以及连接的路径
from concept.
是的,是集成在业务服务中的,但是报错信息是在网关报错的,这个报错触发的比较频繁,客户端访问10次接口几乎有7...8次都报这个错误
from concept.
是不是网关配置的有问题,没报错的时候ws是正常连上的吗
from concept.
我们的业务大概是这样,从前端访问时就开始建立客户端连接,后端接口处理完成后,就将结果返回给前端,并且WS客户端关闭,这个流程应该是没有什么问题吧?
from concept.
过一段时间调用其他接口就会出现这个报错
from concept.
网关配置:
server:
port: xxxxx
spring:
cloud:
gateway:
httpclient:
pool:
type: fixed
max-idle-time: 5000
max-connections: 200
acquire-timeout: 45000
connect-timeout: 2000
response-timeout: 60s
globalcors: # 全局的跨域处理
add-to-simple-url-handler-mapping: true # 解决options请求被拦截问题,配置后CORS的询问请求就会正常放出
corsConfigurations:
'[/**]': # 拦截哪些请求,/**是拦截一切的请求
allowedOriginPatterns: ""
allowedMethods: # 允许的跨域ajax的请求方式
- "GET"
- "POST"
- "DELETE"
- "PUT"
- "OPTIONS"
allowedHeaders: "" # 允许在请求中携带的头信息
allowCredentials: true # 是否允许携带cookie
maxAge: 360000 # 这次跨域检测的有效期
# 自动服务发现
discovery:
locator:
enabled: true
filters:
- PreserveHostHeader
from concept.
有没有简单的demo能复现的,你们的流程是:连上之后,调接口(可能会有问题),数据返回,断开连接?
from concept.
调接口然后触发onEstablish?不是先连上触发onEstablish再调接口吗
from concept.
先连上,然后触发onEstablish,此时websockect处于连接状态,等后台操作完成后,就通知前端,前端接收到后台的通知,就应该是调用onClose,然后关闭了连接
from concept.
2023-12-20 20:28:43.259 [z-gateway,,] [reactor-http-epoll-2] ERROR reactor.core.publisher.Operators-[315] - Operator called default onErrorDropped
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: WebSocket close status code does NOT comply with RFC-6455: 1005
Caused by: java.lang.IllegalArgumentException: WebSocket close status code does NOT comply with RFC-6455: 1005
at io.netty.handler.codec.http.websocketx.CloseWebSocketFrame.requireValidStatusCode(CloseWebSocketFrame.java:202)
at io.netty.handler.codec.http.websocketx.CloseWebSocketFrame.(CloseWebSocketFrame.java:69)
at reactor.netty.http.client.WebsocketClientOperations.sendClose(WebsocketClientOperations.java:215)
at org.springframework.web.reactive.socket.adapter.ReactorNettyWebSocketSession.close(ReactorNettyWebSocketSession.java:124)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:125)
at reactor.core.publisher.FluxFilter$FilterSubscriber.onNext(FluxFilter.java:113)
at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:224)
at reactor.core.publisher.FluxFirstWithSignal$FirstEmittingSubscriber.onNext(FluxFirstWithSignal.java:330)
at reactor.core.publisher.Operators$MonoInnerProducerBase.complete(Operators.java:2634)
at reactor.core.publisher.SinkOneMulticast.tryEmitValue(SinkOneMulticast.java:70)
at reactor.netty.http.server.WebsocketServerOperations.sendCloseNow(WebsocketServerOperations.java:260)
at reactor.netty.http.server.WebsocketServerOperations.onInboundNext(WebsocketServerOperations.java:158)
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800)
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:487)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:385)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)
2023-12-20 20:31:43.749 [z-gateway,,] [reactor-http-epoll-12] WARN reactor.netty.http.client.HttpClientConnect-[295] - [4dbd14f2-1, L:/192.168.1.51:60326 - R:xxx.xxx.x.xx/xxx.xxx.x.xx:8198] The connection observed an error, the request cannot be retried as the headers/body were sent
io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer
2023-12-20 20:31:43.751 [z-gateway,,] [reactor-http-epoll-12] WARN com.z.gateway.handler.GlobalExceptionHandler-[46] - Error Spring Cloud Gateway : /z-contract/api/contract/query/selectUserInfo readAddress(..) failed: Connection reset by peer
from concept.
我写了一个简单的demo走你说的流程,没有复现你说的问题,你可以看下是不是这样的逻辑
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button onclick="test()">Test</button>
</body>
<script>
function test() {
//创建websocket实例
let websocket = new WebSocket('ws://localhost:9000/user/concept-websocket/test');
//连接成功时的回调函数
websocket.onopen = function () {
console.log('连接成功');
//http
const http = new XMLHttpRequest();
const url='http://localhost:9000/user/ws/send';
http.open("GET", url);
http.send();
http.onreadystatechange = () => {
console.log(http.status)
}
}
//接收到服务端消息时的回调函数
websocket.onmessage = function (e) {
console.log('接收到消息', e.data);
websocket.close(1000)
}
//连接关闭时的回调函数
websocket.onclose = function () {
console.log('连接关闭');
}
//连接异常时的回调函数
websocket.onerror = function () {
console.log('连接异常');
}
}
</script>
</html>
from concept.
2023-12-20 20:28:43.259 [z-gateway,,] [reactor-http-epoll-2] ERROR reactor.core.publisher.Operators-[315] - Operator called default onErrorDropped
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: WebSocket close status code does NOT comply with RFC-6455: 1005
Caused by: java.lang.IllegalArgumentException: WebSocket close status code does NOT comply with RFC-6455: 1005
at io.netty.handler.codec.http.websocketx.CloseWebSocketFrame.requireValidStatusCode(CloseWebSocketFrame.java:202)
at io.netty.handler.codec.http.websocketx.CloseWebSocketFrame.(CloseWebSocketFrame.java:69)
at reactor.netty.http.client.WebsocketClientOperations.sendClose(WebsocketClientOperations.java:215)
at org.springframework.web.reactive.socket.adapter.ReactorNettyWebSocketSession.close(ReactorNettyWebSocketSession.java:124)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:125)
at reactor.core.publisher.FluxFilter$FilterSubscriber.onNext(FluxFilter.java:113)
at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:224)
at reactor.core.publisher.FluxFirstWithSignal$FirstEmittingSubscriber.onNext(FluxFirstWithSignal.java:330)
at reactor.core.publisher.Operators$MonoInnerProducerBase.complete(Operators.java:2634)
at reactor.core.publisher.SinkOneMulticast.tryEmitValue(SinkOneMulticast.java:70)
at reactor.netty.http.server.WebsocketServerOperations.sendCloseNow(WebsocketServerOperations.java:260)
at reactor.netty.http.server.WebsocketServerOperations.onInboundNext(WebsocketServerOperations.java:158)
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800)
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:487)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:385)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)
2023-12-20 20:31:43.749 [z-gateway,,] [reactor-http-epoll-12] WARN reactor.netty.http.client.HttpClientConnect-[295] - [4dbd14f2-1, L:/192.168.1.51:60326 - R:xxx.xxx.x.xx/xxx.xxx.x.xx:8198] The connection observed an error, the request cannot be retried as the headers/body were sent
io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection reset by peer
2023-12-20 20:31:43.751 [z-gateway,,] [reactor-http-epoll-12] WARN com.z.gateway.handler.GlobalExceptionHandler-[46] - Error Spring Cloud Gateway : /z-contract/api/contract/query/selectUserInfo readAddress(..) failed: Connection reset by peer
你是不是前端关闭的时候没有传code,传1000试一下
from concept.
Related Issues (20)
- 使用RABBIT_FANOUT转发消息解析异常 HOT 3
- 启动多个服务实例,实例之间无法连接 HOT 11
- 如果发送消息量过大或者base64图片的时候会直接关闭socket能够通过配置解决? HOT 16
- 支持不用注册中心的版本吗? HOT 1
- 长文本支持要怎么设置 HOT 1
- 异步回调转为同步返回 HOT 5
- 发现发送消息会一直占用 发生java.lang.OutOfMemoryError: Java heap space HOT 12
- 消息转发json转义 HOT 13
- websocket连接过多 HOT 2
- 如何主动关闭集群其它机器的 websocket 连接 HOT 2
- springboot3.2.4 Download组件报错 HOT 2
- SpringBoot 3.2.5 Download组件报错
- 自身实例去连接其他实例时报404 HOT 8
- 如果有server.servlet.context-path的话会导致自身实例连接订阅其他实例失败且PathMessage全部变成死信消息导致接收不到 HOT 3
- 批量发送concept.send(..) HOT 1
- concept-downlaod 下载文件可以指定目录么, HOT 7
- concept-downlaod可以下载到服务器指定路径 HOT 34
- 大量websocket连接优化 HOT 44
- websocket如何鉴权 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from concept.