{
  "id": 12270321,
  "title": "WebSocket Support for Your Java Backend",
  "url": "https://urgent.news/2026/10/06/websocket-support-for-your-java-backend",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-06T00:59:55.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/codenameone/websocket-support-for-your-java-backend-4fak"
  },
  "original_language": "en",
  "account": "A Java backend now supports WebSockets, allowing for real-time, two-way communication between the server and client. Codename One, an open-source framework for building native apps, now includes RFC 6455 WebSockets support with Java callbacks for text and binary messages. The client API, com.codename1.io.WebSocket, remains unchanged and can be used as before. The release adds the server half, com.codename1.backend.WebSocket, and @WebSocketMapping annotation to register an endpoint. The framework demonstrates this by building a small endpoint in the backend module of a Codename One project. This endpoint can then be connected to using WebSocket via ws://localhost:8080/echo. The current receiver, Cn1ssScreenshotServer in the backend demo tree, is used in Codename One's primary screenshot infrastructure, but it hasn't replaced every host-side test tool. The benefits include exercising the public WebSocket implementation with a workload that produces artifacts for inspection. The backend uses virtual threads instead of operating-system threads for long-lived connections, allowing for better resource management. Connection-specific state should be stored on WebSocketSession using setAttachment, rather than in a shared field. The server supports a five-minute idle timeout and a message size limit of 2MB, which can be adjusted based on the workload's needs. Sending large amounts of data or broadcasting messages can cause back pressure, so it's recommended to use bounded application work queues and an appropriate sending pool to avoid stalling.",
  "summary": "A job finishes on the server. The app should know about it without asking the same HTTP endpoint every few seconds. WebSockets keep a two-way connection open so either side can send a message when there's something to report. What is Codename One? Codename One is an open-source framework for building native iOS, Android, desktop, and web apps from a single Java or Kotlin codebase. Learn more at…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}