Skip to content

Commit

Permalink
bugfix: fixed disconnect from websocket. Set time to first message.
Browse files Browse the repository at this point in the history
  • Loading branch information
Troha7 committed Mar 17, 2024
1 parent 67d7e73 commit 518fe56
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;

@Configuration
@EnableWebSocketMessageBroker
Expand All @@ -25,4 +26,11 @@ public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint(properties.getEndpoint());
registry.addEndpoint(properties.getEndpoint()).setAllowedOriginPatterns("*").withSockJS();
}


@Override
public void configureWebSocketTransport(WebSocketTransportRegistration registry) {
registry.setTimeToFirstMessage(properties.getTimeToFirstMessage());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ public class WebsocketProperties {
private String topicPrefix;
private String notifyPrefix;
private String errorPrefix;
private int TimeToFirstMessage;

}
5 changes: 3 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spring.data.redis.password=${REDIS_PASSWORD:admin}

#Hibernate
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=true
#spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto=validate

Expand All @@ -30,6 +30,7 @@ socket.endpoint=/chat
socket.topic-prefix=/topic
socket.notify-prefix=/specific/notify
socket.error-prefix=/specific/error
socket.time-to-first-message=999999

#Security:
security.jwt.token-type=Bearer
Expand Down Expand Up @@ -58,5 +59,5 @@ spring.mail.properties.mail.smtp.starttls.required=true
message.max.amount.reports=2

#Logging:
logging.level.com.chat.yourway=${LOGGING_LEVEL:info}
logging.level.com.chat.yourway=${LOGGING_LEVEL:trace}

0 comments on commit 518fe56

Please sign in to comment.