Skip to content

💬 WebSocket Inspector

Flocon captures all WebSocket communications made by your application, giving you complete visibility into live feeds, chats, and multiplayer events.


Overview

WebSocket Inspection in Flocon

For every active WebSocket connection, Flocon records:

  • Connection Lifecycle: Connection URL, handshake status, opening timestamps, and closure codes
  • Frames: Sent and received text frames, binary payloads, and ping/pong heartbeats
  • Order & Timestamps: Precise sequential message ordering with millisecond timestamps

Setup & Integration

With OkHttp (Android)

Flocon provides built-in WebSocket extension helpers for OkHttp:

// Sends the message and simultaneously logs it to Flocon
webSocket.sendWithFlocon("\"$messagePayload\"")
val request = Request.Builder()
    .url("wss://your-websocket-endpoint.com")
    .build()

val myListener = object : WebSocketListener() {
    override fun onMessage(webSocket: WebSocket, text: String) {
        // Your handler
    }
}

// Wraps the listener to record all incoming frames in Flocon
val webSocket = client.newWebSocket(
    request,
    myListener.listenWithFlocon(id = "wss://your-websocket-endpoint.com")
)

Manual Logging (Kotlin Multiplatform)

If you use custom WebSocket implementations (or multiplatform WebSocket engines), forward events directly via floconLogWebSocketEvent:

floconLogWebSocketEvent(
    FloconWebSocketEvent(
        websocketUrl = "wss://api.example.com/ws",
        event = FloconWebSocketEvent.Event.SendMessage,
        message = outgoingText,
    )
)
floconLogWebSocketEvent(
    FloconWebSocketEvent(
        websocketUrl = "wss://api.example.com/ws",
        event = FloconWebSocketEvent.Event.ReceiveMessage,
        message = incomingText,
    )
)