Java jhipster EventSource请求超时
我对jhipster中的javascriptJava jhipster EventSource请求超时,java,spring-boot,jhipster,spring-webflux,Java,Spring Boot,Jhipster,Spring Webflux,我对jhipster中的javascriptEventSource有问题。我在一个普通的Spring启动应用程序中使用了Spring boot webflux的EventSource。在该项目中,当用户订阅/chat/subscribe时,连接会在长时间不活动的情况下保持打开状态(我测试了30分钟)。我没有在我的spring boot应用程序中使用任何配置。但是当我在jhipster应用程序中使用EventSource时,连接会在不活动2分钟后关闭。我不知道jhipster在哪里设置了这个配置。
EventSource
有问题。我在一个普通的Spring启动应用程序中使用了Spring boot webflux的EventSource
。在该项目中,当用户订阅/chat/subscribe
时,连接会在长时间不活动的情况下保持打开状态(我测试了30分钟)。我没有在我的spring boot应用程序中使用任何配置。但是当我在jhipster应用程序中使用EventSource
时,连接会在不活动2分钟后关闭。我不知道jhipster在哪里设置了这个配置。这是我的密码:
控制器:
@Controller
@RequestMapping("/api")
public class ChatResource {
@Autowired
@Qualifier("ptpReplayProcessor")
private ReplayProcessor<String> ptpReplayProcessor;
@GetMapping(value = "/chat/subscribe", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@ResponseBody
public Flux<String> subscribe() {
return Flux.from(ptpReplayProcessor);
}
}
发送消息并调用ptpReplayProcessor.onNext(message)
时,浏览器会记录消息,一切正常。但是,如果我在2分钟内没有发送任何消息,浏览器控制台将显示错误
!。我想知道为什么这个问题只存在于jhipster中,而不存在于普通的spring引导应用程序中!
谢谢你的关注
@Configuration
public class ReplayProcessorConfig {
@Bean("ptpReplayProcessor")
ReplayProcessor<String> ptpReplayProcessor() {
ReplayProcessor<String> replayProcessor = ReplayProcessor.create(0, false);
replayProcessor.subscribe(new BaseSubscriber<String>() {
@Override
protected void hookOnNext(String ptp) {
System.out.println("ptp replay processor called!");
}
});
return replayProcessor;
}
}
....
this.source = new EventSource('http://localhost:9000/api/chat/subscribe');
this.source.onmessage = event => {
console.log(event);
};
this.source.onerror = event => {
console.log('error');
};