grpc/grpc-java · error · UnsupportedOperationException

Unsupported operation sendUrgentData()

Error message

Unsupported operation sendUrgentData()

What it means

Sentinel guard in UdsSocket's Socket adapter: UDS (Unix domain) local sockets have no TCP out-of-band data channel, so the Socket.sendUrgentData override unconditionally rejects the operation. It fires whenever calling code assumes a plain TCP socket and attempts to send urgent/OOB data on this wrapper.

Solutions

  1. Do not use out-of-band data on UDS sockets; send a normal application-level ping/RPC instead
  2. Implement liveness checks at the gRPC level (e.g. grpc.health.v1 Health checks) rather than at the socket level
  3. Refactor shared socket utilities to branch on socket type before calling TCP-only methods

Example fix

// before
socket.sendUrgentData(0xFF); // TCP OOB liveness probe
// after
// use gRPC health checking instead of TCP urgent data
healthStub.check(HealthCheckRequest.getDefaultInstance());
Defensive patterns

Strategy: fallback

Validate before calling

boolean supportsOob = !(socket instanceof io.grpc.android.UdsSocket);

Type guard

static boolean supportsUrgentData(java.net.Socket s) { return !(s instanceof io.grpc.android.UdsSocket); }

Try / catch

try { socket.sendUrgentData(data); } catch (UnsupportedOperationException e) { /* fall back to app-level ping */ }

Prevention

When it happens

Trigger: Calling UdsSocket.sendUrgentData(int) directly, or code performing TCP keep-alive/liveness probes via out-of-band bytes on the socket.

Common situations: Porting legacy TCP socket health-check code that pings the peer with urgent data; reusing a shared socket-utility class against the UDS transport.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of grpc/grpc-java@64daddc1f3 (2026-09-08). Data as JSON: /api/errors/0cd59df1d0033681. Report an issue: GitHub.

Appendix: source

Thrown at android/src/main/java/io/grpc/android/UdsSocket.java:230

  @Override
  public boolean isConnected() {
    return localSocket.isConnected();
  }

  @Override
  public synchronized boolean isInputShutdown() {
    return inputShutdown;
  }

  @Override
  public synchronized boolean isOutputShutdown() {
    return outputShutdown;
  }

  @Override
  public void sendUrgentData(int data) {
    throw new UnsupportedOperationException("Unsupported operation sendUrgentData()");
  }

  @Override
  public void setKeepAlive(boolean on) {
    throw new UnsupportedOperationException("Unsupported operation setKeepAlive()");
  }

  @Override
  public void setOOBInline(boolean on) {
    throw new UnsupportedOperationException("Unsupported operation setOOBInline()");
  }

  @Override
  public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
    throw new UnsupportedOperationException("Unsupported operation setPerformancePreferences()");
  }

  @Override

View on GitHub (pinned to 64daddc1f3)