docs: public void write(MessageType msg) throws IllegalStateException {
          byte[] messageBytes = msg.toByteArray();
          checkState(messageBytes.length <= maxMessageSize);
          byte[] messageLength = new byte[4];
          Utils.uint32ToByteArrayBE(messageBytes.length, messageLength, 0);
          try {
              MessageWriteTarget target = writeTarget.get();
              target.writeBytes(messageLength);
              target.writeBytes(messageBytes);
          } catch (IOException e) {
              closeConnection();
          }
      }