I'm trying to implement a websocket on using Spring Boot (1.5.13).
The messaging works fine but after about 30 minutes the connection is terminated by the server (Reason 1008 - "This connection was established under an authenticated HTTP session that has ended"). I've tried to set different timeouts but doesn't seem to have any effect.
@Service
@RequiredArgsConstructor
@Slf4j
public class OCPPSocketHandler extends TextWebSocketHandler {
@Override
public void handleTextMessage(WebSocketSession webSocketSession, TextMessage textMessage)
throws IOException {
...
}
}
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
public static final String ENDPOINT = "/pp/v2.0";
@Autowired
private CustomSocketHandler socketHandler;
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(
new CustomExceptionWebSocketHandlerDecorator(socketHandler), ENDPOINT
)
.setAllowedOrigins("*");
}
}
application.properties:
#6h as milliseconds
server.connection-timeout=3600000
server.servlet.session.timeout=6h
A TextMessage (WebSocket) is sent every 30 minutes to keep the connection alive.
I've seen this question about session timeouts but I can't see a solution there