Closed jlibx closed 1 year ago
Describe the bug SpringCloud Gateway 2.1.1
Sample In the springboot project,I created a SSE Emitter like this:
@GetMapping(value = "/init", produces = "text/event-stream") public SseEmitter init(HttpServletResponse response) throws Exception { response.setCharacterEncoding("UTF-8"); response.setContentType("text/event-stream"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("Connection", "keep-alive"); SseSession sseSession = robotAppService.createSseSession(token()); return sseSession.getSseEmitter(); }
The specific code of RobotAppService is as follows:
public SseSession createSseSession(String token) { SseSession sseSession = sseSessionManager.getSseSession(token); // return existing session if (Objects.nonNull(sseSession)) { return sseSession; } else { Robot robot = robotService.initRobot(token); // this will be create SseEmitter sseSession = sseSessionManager.createSseSession(token, robot); // init dailog RobotDialogDetail robotDialogDetail = robotService.initRobotDialog(robot); robot.setLastDialog(robotDialogDetail); // sse message SseMessage sseMessage = sseMessageFactory.transform(robotDialogDetail); sseSession.sendMessageByRobot(sseMessage); iRedisCache.remove(String.join("", "ymtd:robot:chat:", token)); } return sseSession; }
Request init through the gateway agent, the first time it is normal, and it has been sending after the second time。
i am also facing the similar issue, though the sse service is in javalin in our case
This is right, the SSE service does not have any return body, it will be like this. Make sure you have the return body.
Describe the bug SpringCloud Gateway 2.1.1
Sample In the springboot project,I created a SSE Emitter like this:
The specific code of RobotAppService is as follows:
Request init through the gateway agent, the first time it is normal, and it has been sending after the second time。