code: @Override
      public void writeRaw(IoBuffer out) {
          if (ioSession != null) {
              final Semaphore lock = getLock();
              while (!isClosed()) {
                  boolean acquired = false;
                  try {
                      acquired = lock.tryAcquire(10, TimeUnit.MILLISECONDS);
                      if (acquired) {
                          if (log.isTraceEnabled()) {
                              log.trace("Writing raw message");
                          }
                          ioSession.write(out);
                          break;
                      }
                  } catch (InterruptedException e) {
                      log.warn("Interrupted while waiting for write lock (writeRaw). State: {}", RTMP.states[state.getState()], e);
                      String exMsg = e.getMessage();
                      // if the exception cause is null break out of here to prevent looping until closed
                      if (exMsg == null || exMsg.indexOf("null") >= 0) {
                          log.debug("Exception writing to connection: {}", this);
                          break;
                      }
                  } finally {
                      if (acquired) {
                          lock.release();
                      }
                  }
              }
          }
      }
docs: {@inheritDoc}