Class WebSocketCloseException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    WebSocketCloseException

    public abstract class WebSocketCloseException
    extends java.lang.RuntimeException
    Fail the outgoing message stream of a WebSocket handler with a WebSocketCloseException to close the WebSocket with an application specific close code (3000-4999) and reason. The peer will see the close code and reason (in Akka HTTP as a PeerClosedConnectionException).

    Note that failing a stream may discard messages buffered in stages downstream of the failing stage. An ongoing streamed message is given the close timeout (3 seconds) to finish before the WebSocket is closed.

    Create instances using create.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      WebSocketCloseException​(int closeCode, java.lang.String closeReason)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int closeCode()  
      java.lang.String closeReason()  
      static WebSocketCloseException create​(int closeCode)
      Create an exception closing the WebSocket with the given close code and an empty reason.
      static WebSocketCloseException create​(int closeCode, java.lang.String closeReason)
      Create an exception closing the WebSocket with the given close code and reason.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WebSocketCloseException

        public WebSocketCloseException​(int closeCode,
                                       java.lang.String closeReason)
    • Method Detail

      • create

        public static WebSocketCloseException create​(int closeCode,
                                                     java.lang.String closeReason)
        Create an exception closing the WebSocket with the given close code and reason.

        Parameters:
        closeCode - an application specific close code in the range 3000-4999
        closeReason - a reason, at most 123 bytes when UTF-8 encoded
        Returns:
        (undocumented)
      • create

        public static WebSocketCloseException create​(int closeCode)
        Create an exception closing the WebSocket with the given close code and an empty reason.

        Parameters:
        closeCode - an application specific close code in the range 3000-4999
        Returns:
        (undocumented)
      • closeCode

        public int closeCode()
      • closeReason

        public java.lang.String closeReason()