Outbound Persistent WS connection - Java Spring Boot Websocket

Good afternoon,
I am trying out the Outbound Websocket feature with a Spring Boot Application and having an issue with the connection being created and instantly dropped.

[Nov 30 21:17:11] NOTICE[1518311]: ari/ari_websockets.c:970 outbound_session_handler_thread: spring_connection: Outbound websocket connected to ws://localhost:8080/ws/ari
[Nov 30 21:17:11] WARNING[1518311]: ari/ari_websockets.c:1023 outbound_session_handler_thread: spring_connection: Websocket disconnected. Reconnecting

I have enabled debug logging in spring and I can’t see any errors so I am unsure where/why the connection could be being dropped. Any help or pointers would be greatly appreciated!

@Slf4j
@Configuration
public class WebsocketConfig implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {

DefaultHandshakeHandler defaultHandshakeHandler = new DefaultHandshakeHandler();
defaultHandshakeHandler.setSupportedProtocols("ari");

registry.addHandler(new TextWebSocketHandler() {

@Override
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
log.info("Connection Closed : {} -> {}", status, session.getId());
}

@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
log.info("CONNECTED : {}", session.getId());
}

@Override
protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
log.info(message.getPayload());
}
}, "/ws/ari")
.setAllowedOrigins("*")
.setHandshakeHandler(defaultHandshakeHandler);
}
}

I am a bit stuck and the `vvvvv` isnt revealing much more verbose reasoning as to why the connection is being dropped.

The spring logs (debug):

2025-11-30T21:17:11.727Z INFO 1599037 — [spring-agi] [io-8080-exec-86] c.e.a.s.app.ari.WebsocketConfig : CONNECTED : b65da0f7-eaa6-6727-dfa8-9dc57bf9161c
2025-11-30T21:17:11.727Z INFO 1599037 — [spring-agi] [io-8080-exec-86] c.e.a.s.app.ari.WebsocketConfig : Connection Closed : CloseStatus[code=1000, reason=null] → b65da0f7-eaa6-6727-dfa8-9dc57bf9161c

Is your spring app set up to route /ws/ari properly?

Your best bet would be to run wireshark on port 8080 to see what’s happening at the protocol level.

Sorry I am quite new to wireshark so didn’t know how to exactly get a text output of the packets.

But I can see it seems that its Asterisk that is sending the FIN/Normal close to Spring Boot an I am unsure as to why.

I’d need to see the complete content of the HTTP 101 response from the app and the configuration entries from both ari.conf and websocket_client.conf.

You can also turn debugging on to get more info. Add the following lines to your cli.conf file and make sure you’re logging DEBUG messages to one of the log channels in logger.conf, then restart asterisk…

[startup_commands]
core set debug 4 res_websocket_client.so = pre-module
core set debug 4 ari/ari_websockets.c = pre-module
core set debug 4 res_ari.so = pre-module
core set debug 4 res_http_websocket.so = pre-module

Thank you, I ended up just reinstalling everything and it works.
I assume I must have had some bad configuration somewhere which prevented the outbound websocket. I have a feeling it was something I had in the global ari.conf settings.