@@ -5,6 +5,7 @@ import io.github.resilience4j.retry.annotation.Retry
55import net.leanix.githubagent.handler.BrokerStompSessionHandler
66import net.leanix.githubagent.services.LeanIXAuthService
77import net.leanix.githubagent.shared.GitHubAgentProperties.GITHUB_AGENT_VERSION
8+ import org.slf4j.LoggerFactory
89import org.springframework.context.annotation.Bean
910import org.springframework.context.annotation.Configuration
1011import org.springframework.messaging.converter.MappingJackson2MessageConverter
@@ -25,11 +26,19 @@ class WebSocketClientConfig(
2526 private val leanIXProperties : LeanIXProperties ,
2627 private val gitHubEnterpriseProperties : GitHubEnterpriseProperties
2728) {
29+ private val logger = LoggerFactory .getLogger(WebSocketClientConfig ::class .java)
30+
2831 @Retry(name = " ws_init_session" )
2932 fun initSession (): StompSession {
3033 val headers = WebSocketHttpHeaders ()
3134 val stompHeaders = StompHeaders ()
32- stompHeaders[" Authorization" ] = " Bearer ${leanIXAuthService.getBearerToken()} "
35+ stompHeaders[" Authorization" ] = runCatching {
36+ " Bearer ${leanIXAuthService.getBearerToken()} "
37+ }.getOrElse {
38+ logger.error(" Failed to get Bearer token for WebSocket connection, please check your Technical User token" )
39+ logger.info(" Retrying to connect..." )
40+ throw it
41+ }
3342 stompHeaders[" GitHub-Enterprise-URL" ] = gitHubEnterpriseProperties.baseUrl
3443 stompHeaders[" GitHub-Agent-Version" ] = GITHUB_AGENT_VERSION
3544 return stompClient().connectAsync(
0 commit comments