Skip to content

Commit 9e94561

Browse files
Merge pull request #131 from leanix/feature/CID-3982/enhance-expired-technical-user-logging
CID-3982: Enhance expired/wrong technical user flow
2 parents 39fc624 + c299dcb commit 9e94561

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/kotlin/net/leanix/githubagent/config/WebSocketClientConfig.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import io.github.resilience4j.retry.annotation.Retry
55
import net.leanix.githubagent.handler.BrokerStompSessionHandler
66
import net.leanix.githubagent.services.LeanIXAuthService
77
import net.leanix.githubagent.shared.GitHubAgentProperties.GITHUB_AGENT_VERSION
8+
import org.slf4j.LoggerFactory
89
import org.springframework.context.annotation.Bean
910
import org.springframework.context.annotation.Configuration
1011
import 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

Comments
 (0)