Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot Websocket不适用于GAE(谷歌应用程序引擎)_Spring Boot_Google App Engine_Websocket_Stomp - Fatal编程技术网

Spring boot Websocket不适用于GAE(谷歌应用程序引擎)

Spring boot Websocket不适用于GAE(谷歌应用程序引擎),spring-boot,google-app-engine,websocket,stomp,Spring Boot,Google App Engine,Websocket,Stomp,我在SpringBoot+react应用程序中使用websocket,该应用程序运行良好,现在我正在GAE上部署该应用程序(它有四个实例,最多可以扩展到6个实例) 但在这里,websocket并没有正常工作 正在创建websocket连接,但响应不是来自后端如果我刷新页面,则有时它会工作,如果再次刷新,则它不会工作 下面是在React js中创建websocket连接的参考代码:- @action connectToWebSocket = (channelName) => {

我在SpringBoot+react应用程序中使用websocket,该应用程序运行良好,现在我正在GAE上部署该应用程序(它有四个实例,最多可以扩展到6个实例)

但在这里,websocket并没有正常工作

正在创建websocket连接,但响应不是来自后端如果我刷新页面,则有时它会工作,如果再次刷新,则它不会工作

下面是在React js中创建websocket连接的参考代码:-

  @action connectToWebSocket = (channelName) => {
    this.webSocketInitilization();
    this.stompClient.connect({}, this.connectSocket, this.onError);
}

@action webSocketInitilization = () => {
      this.socket = new SockJS('/wss');
     this.stompClient = Stomp.over(this.socket);
     this.stompClient.debug = null
}

connectSocket = () => {
  this.subscription = this.stompClient.subscribe("/topic/model_" + this.modelId, this.onMessageReceived);
    console.log("connection created");
}
后端配置文件:-

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
 
    registry.addEndpoint("/wss").setAllowedOrigins("*").withSockJS();
}

@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
    registry.setApplicationDestinationPrefixes("/app");
    registry.enableSimpleBroker("/topic");   // Enables a simple in-memory broker

}
}

不确定是什么问题可能与GAE配置有关

已编辑:-正在添加app.yml文件 我对此进行了研究,所以人们说这个参数
session\u affinity:true
只适用于
beta
版本,之前我有另一个版本,所以我更新了我的版本,但这个参数仍然没有反映在我的应用程序引擎配置中

关于错误日志:-令人惊讶的是,我没有在浏览器控制台和GAE日志中获得任何错误日志


有什么帮助吗?

您能提供一条错误消息吗?你的GAE日志中应该有一些东西可以帮助我们。另外,阅读有关会话亲缘关系的内容可能会很有趣。如果不起作用,请附加app.yaml文件。@Ajordat我编辑了我的问题。您能否尝试运行@Ajorda提供的示例中的示例,以定位ws日志的显示方式,并检测ws连接何时关闭并重新连接?您还可以尝试将实例数减少到1,以检查问题是否仍然存在。
runtime: java
env: flex

resources:
    memory_gb: 6.5
    cpu: 4
   disk_size_gb: 20
   automatic_scaling: 
   min_num_instances: 4 
   max_num_instances: 8
   cpu_utilization: 
   target_utilization: 0.6
handlers:
  - url: /.*
  script: this field is required, but ignored
network:
   session_affinity: true