libgdx/libgdx · error · UnsupportedOperationException

Not implemented

Error message

Not implemented

What it means

Net.newServerSocket throws UnsupportedOperationException("Not implemented") in the GWT backend because browsers cannot open listening TCP sockets. The Net interface includes raw socket APIs, but only the HTTP subset is implementable in a browser sandbox.

Source

Thrown at backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtNet.java:208

		HttpResponseListener httpResponseListener = listeners.get(httpRequest);
		Request request = requests.get(httpRequest);

		if (httpResponseListener != null && request != null) {
			request.cancel();
			httpResponseListener.cancelled();
			requests.remove(httpRequest);
			listeners.remove(httpRequest);
		}
	}

	@Override
	public boolean isHttpRequestPending (HttpRequest httpRequest) {
		return listeners.get(httpRequest) != null && requests.get(httpRequest) != null;
	}

	@Override
	public ServerSocket newServerSocket (Protocol protocol, String hostname, int port, ServerSocketHints hints) {
		throw new UnsupportedOperationException("Not implemented");
	}

	@Override
	public ServerSocket newServerSocket (Protocol protocol, int port, ServerSocketHints hints) {
		throw new UnsupportedOperationException("Not implemented");
	}

	@Override
	public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {
		throw new UnsupportedOperationException("Not implemented");
	}

	@Override
	public boolean openURI (String URI) {
		if (config.openURLInNewWindow) {
			Window.open(URI, "_blank", null);
		} else {
			Window.Location.assign(URI);

View on GitHub (pinned to 97f4086187)

Solutions

  1. Do not host servers in the browser: move the server to a dedicated process and have the GWT client connect via WebSocket or HTTP
  2. Guard server-socket creation with Gdx.app.getType() != ApplicationType.WebGL and skip/notify on web
  3. Abstract Net usage behind an interface with a WebGL implementation that only supports client HTTP/WebSocket

Example fix

// before
ServerSocket server = Gdx.net.newServerSocket(Protocol.TCP, port, null);

// after
if (Gdx.app.getType() != ApplicationType.WebGL) {
    ServerSocket server = Gdx.net.newServerSocket(Protocol.TCP, port, null);
} else {
    // connect to an external WebSocket server instead
}
Defensive patterns

Strategy: validation

Validate before calling

static boolean canHostSockets () {
    return Gdx.app.getType() != ApplicationType.WebGL;
}

Prevention

When it happens

Trigger: Calling Gdx.net.newServerSocket(protocol, hostname, port, hints) or the port-only overload on the GWT backend; any attempt to host a socket server from the HTML5 build.

Common situations: Multiplayer code that hosts a local TCP server on desktop being reused in the HTML5 target; tooling that assumes the full Net API exists on every backend.

Related errors


AI-assisted analysis of libgdx/libgdx@97f4086187 (2026-08-14). Data as JSON: /api/errors/c72b528ac811b2e9. Report an issue: GitHub.