Send NetStream.Play.Failed to the client.

@param conn
@param errorCode
@param description
@param name
@param streamId
502548
private void sendNSFailed(IConnection conn, String errorCode, String description, String name, Number streamId) {
        StreamService.sendNetStreamStatus(conn, errorCode, description, name, Status.ERROR, streamId);
    }
1107623
public void error(VirtualConnection vc, TCPReadRequestContext req, IOException ioe) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "error: " + vc);
        }
        // This can legitemately happen if the client closes
        // the connection before sending data - we will always get
        // an exception in that case
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Error occurred during initial read of request from client: " + req.getInterface().getRemoteAddress() + " " + req.getInterface().getRemotePort() + " : "
                         + ioe);
        }

        // release any WsByteBuffers that were allocated for this request
        WsByteBuffer buffArray[] = req.getBuffers();
        if (buffArray != null) {
            for (int i = 0; i < buffArray.length; i++) {
                if (buffArray[i] != null) {
                    buffArray[i].release();
                }
            }
        }
        req.setBuffers(null);

        // if read timed out, send to discriminators so that they
        // can send error response if necessary
        if (ioe != null && ioe instanceof SocketTimeoutException) {
            sendToDiscriminators(vc, req, true);
        } else {
            // Destroy the connection link
            ((TCPReadRequestContextImpl) req).getTCPConnLink().close(vc, ioe);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "error");
        }
    }
1071939
private ChannelFuture resetUnknownStream(final ChannelHandlerContext ctx, int streamId, long errorCode,
                                             ChannelPromise promise) {
        ChannelFuture future = frameWriter().writeRstStream(ctx, streamId, errorCode, promise);
        if (future.isDone()) {
            closeConnectionOnError(ctx, future);
        } else {
            future.addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    closeConnectionOnError(ctx, future);
                }
            });
        }
        return future;
    }
1355214
public void recordConnectionError(String trackerName) {
    synchronized (this) {
      NodeUsageReport usageReport = getReportUnprotected(trackerName);
      usageReport
          .setNumFailedConnections(usageReport.getNumFailedConnections() + 1);
    }
  }
282826
public void error(MEConnection conn, Throwable ex)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "error", new Object[] { this, conn, ex});

    // This one goes straight to the CEL
    _commsErrorListener.error(conn, ex);

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "error");
  }
1146664
public void log(Throwable error, String description) {
    log(error, null, description, null);
  }
1361169
@Override
    public void error(com.ibm.wsspi.channelfw.VirtualConnection vc, com.ibm.wsspi.tcpchannel.TCPWriteRequestContext wsc, IOException ioe) {
        // This error is a TCP callback.

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())  
            Tr.debug(tc, "error callback called , WriteListener enabled: " + this._wl); 

        this.error(vc, ioe); 

    }
1324525
private void sendSOCreationFailed(RTMPConnection conn, SharedObjectMessage message) {
        log.debug("sendSOCreationFailed - message: {} conn: {}", message, conn);
        // reset the object so we can re-use it
        message.reset();
        // add the error event
        message.addEvent(new SharedObjectEvent(ISharedObjectEvent.Type.CLIENT_STATUS, "error", SO_CREATION_FAILED));
        if (conn.isChannelUsed(3)) {
            // XXX Paul: I dont like this direct write stuff, need to move to event-based
            conn.getChannel(3).write(message);
        } else {
            log.warn("Channel is not in-use and cannot handle SO event: {}", message, new Exception("SO event handling failure"));
            // XXX Paul: I dont like this direct write stuff, need to move to event-based
            conn.getChannel(3).write(message);
        }
    }
933170
public void sendError(HttpServletRequest req, HttpServletResponse res, ServletErrorReport error) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
            logger.entering(CLASS_NAME, "sendError", "error :" + error.getMessage());

        req.setAttribute("javax.servlet.jsp.jspException", error);
        
        WebContainerRequestState reqState = WebContainerRequestState.getInstance(true);   //PI80786

        // PK82794
        if (WCCustomProperties.SUPPRESS_LAST_ZERO_BYTE_PACKAGE)
            reqState.setAttribute("com.ibm.ws.webcontainer.suppresslastzerobytepackage", "true");
        // PK82794

        if (!res.isCommitted())
            res.resetBuffer();

        String servletName = error.getTargetServletName();

        // begin PK04668 IF THE CLIENT THAT MADE THE SERVLET REQUEST GOES
        // DOWN,THERE IS WAS.webcontainer
        Throwable rootCause = error.getRootCause();
        if (rootCause instanceof ClosedConnectionException) {
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                logger.logp(Level.FINE, CLASS_NAME, "sendError",
                        "sendError occured as a result of ClosedConnectionException. skip sending error page to client");
                if (rootCause.getCause() != null)
                    logger.logp(Level.FINE, CLASS_NAME, "sendError", "cause of closed connection", rootCause.getCause());
            }
            eventSource.onServletServiceError(new ServletErrorEvent(this, this, servletName, null, error));
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
                logger.exiting(CLASS_NAME, "sendError", "ClosedConnectionException");
            return;
        } else if (rootCause instanceof javax.servlet.UnavailableException) {
            // end PK04668 IF THE CLIENT THAT MADE THE SERVLET REQUEST GOES
            // DOWN,THERE IS WAS.webcontainer
            // 198256 - begin
            // if (error instanceof WebAppErrorReport)
            // {
            // ((WebAppErrorReport)
            // error).setErrorCode(HttpServletResponse.SC_NOT_FOUND);
            // }
            // 198256 - end
            this.eventSource.onServletServiceDenied(new ServletErrorEvent(this, this, servletName, null, error));
        }
        
        //PI80786 set error code to 400 to avoid logging as 500
        if (SET_400_SC_ON_TOO_MANY_PARENT_DIRS){
            if(reqState.getAttribute("com.ibm.ws.webcontainer.set400") != null) {
                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                    logger.logp(Level.FINE, CLASS_NAME, "sendError", "Setting the status code to 400");
                }
                error.setErrorCode(HttpServletResponse.SC_BAD_REQUEST);
                reqState.removeAttribute("com.ibm.ws.webcontainer.set400");
            }
        }
        //PI80786

        if (error.getErrorCode() >= 500) {
            if (servletName == null)
                // Defect 211450
                logError(error.getUnencodedMessage(), error);
            else {
                eventSource.onServletServiceError(new ServletErrorEvent(this, this, servletName, null, error));
                logTrace(error.getUnencodedMessage(), error);
            }
        }

        if (req.getAttribute(ServletErrorReport.ATTRIBUTE_NAME) != null) {
            // we are in a recursive situation...report a recursive error
            ServletErrorReport oError = (ServletErrorReport) req.getAttribute(ServletErrorReport.ATTRIBUTE_NAME);
            reportRecursiveError(req, res, oError, error);
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
                logger.exiting(CLASS_NAME, "sendError", "recursive error");
            return;
        }

        // set the error code in the response
        try {
            // if the error code hasn't been set, set it to server error
            if (error.getErrorCode() < 100 || error.getErrorCode() > 599) {
                error.setErrorCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            }

            // d124698 - set the status code attribute in the request

            req.setAttribute(javax.servlet.RequestDispatcher.ERROR_STATUS_CODE, new Integer(error.getErrorCode()));

            // set the response status
            res.setStatus(error.getErrorCode());

            // We have to determine the charset to use with the error page
            String clientEncoding = req.getCharacterEncoding();
            // PK21127 start
            if (clientEncoding != null && !EncodingUtils.isCharsetSupported(clientEncoding)) {
                // charset not supported, continue with the logic to determine
                // the encoding
                clientEncoding = null;
            }
            // PK21127 end
            if (clientEncoding == null)
                clientEncoding = com.ibm.wsspi.webcontainer.util.EncodingUtils.getEncodingFromLocale(req.getLocale());
            if (clientEncoding == null)
                clientEncoding = System.getProperty("default.client.encoding");
            if (clientEncoding == null)
                clientEncoding = "ISO-8859-1";

            res.setContentType("text/html;charset=" + clientEncoding);
        } catch (IllegalStateException ise) {
            // failed to set status code.
            // This could be caused by:
            // 1. the servlet is being included.
            // 2. the stream response is already committed
            com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(ise, CLASS_NAME + ".handleError", "865", this);
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
                logger.logp(Level.FINE, CLASS_NAME, "sendError", "WebApp.sendError() failed to set status code.\n"
                                                                 + "This may be caused by a servlet calling response.sendError() "
                                                                 + "while being included or after the response has already been committed to the client.", ise);
        }

        // set the exception as an error bean in the response
        req.setAttribute(ServletErrorReport.ATTRIBUTE_NAME, error);

        // get this request's error page dispatcher
        RequestDispatcher rd = null;
        try {
            rd = getErrorPageDispatcher(req, error);
        } catch (MajorHandlingRuntimeException e) {
            //If there was a major problem like the application has stopped from under us, we will throw this
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {//306998.15
                logger.logp(Level.FINE, CLASS_NAME, "sendError", "sending sendUnavailableException for context: ["+req.getContextPath()+"]");
            }
            try {
                WebContainer.sendAppUnavailableException(req, res);
            } catch (IOException e1) {
                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {//306998.15
                    logger.logp(Level.FINE, CLASS_NAME, "sendError", "", e);
                }
            }
            return;
        }

        // PK37608 Start
        if (WCCustomProperties.SUPPRESS_WSEP_HEADER) {

            Enumeration ViaHeaderValues = req.getHeaders("Via");

            if (ViaHeaderValues != null) {
                boolean foundODRHeader = false;
                while (!foundODRHeader && ViaHeaderValues.hasMoreElements()) {

                    String ViaHeaderValue = (String) ViaHeaderValues.nextElement();

                    if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                        logger.logp(Level.FINE, CLASS_NAME, "sendError", "Via Header value : " + ViaHeaderValue);
                    }

                    if (ViaHeaderValue.indexOf("On-Demand Router") != -1) {

                        foundODRHeader = true;

                        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                            logger.logp(Level.FINE, CLASS_NAME, "sendError", "Via Header with On-Demand Router found, add $WSEP header to response.");
                        }

                        res.addHeader("$WSEP", "");

                    }
                }

                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE) && foundODRHeader == false) {
                    logger.logp(Level.FINE, CLASS_NAME, "sendError",
                            "No Via header found with On-Demand Router. Do not add $WSEP header to response.");
                }

            } else if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                logger.logp(Level.FINE, CLASS_NAME, "sendError", "No Via Header, do not add $WSEP header to response.");
            }

        } else {

            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                logger.logp(Level.FINE, CLASS_NAME, "sendError", "Add $WSEP header to response.");
            }

            res.addHeader("$WSEP", "");
        }
        // PK37608 End

        try {
            if (rd == null) {
                //PI09474 Start
                // PK23428 BEGIN
                try {

                    PrintWriter pw = res.getWriter();
                    if( WCCustomProperties.DISPLAY_TEXT_WHEN_NO_ERROR_PAGE_DEFINED == null) {
                        // PM03788 Start
                        if (WCCustomProperties.SET_UNENCODED_HTML_IN_SENDERROR) {
                            pw.println(error.getUnencodedMessageAsHTML());
                        }
                        else {
                            if (WCCustomProperties.INCLUDE_STACK_IN_DEFAULT_ERROR_PAGE || this.isLocalAddr(req.getRemoteAddr())) {
                                pw.println(error.getDebugMessageAsHTML());
                            } else {
                                pw.println(error.getMessageAsHTML());
                            }
                        }// PM03788 End
                    }
                    else {
                        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                            logger.logp(Level.FINE, CLASS_NAME, "sendError", "display custom error text provided in the property");
                        }
                        pw.println(WCCustomProperties.DISPLAY_TEXT_WHEN_NO_ERROR_PAGE_DEFINED);
                    }
                } catch (IllegalStateException ise) {
                    ServletOutputStream os = res.getOutputStream();
                    reqState.setAttribute("com.ibm.ws.webcontainer.AllowWriteFromE", true); 
                    if( WCCustomProperties.DISPLAY_TEXT_WHEN_NO_ERROR_PAGE_DEFINED == null) {                                             
                        // PM03788 Start
                        if (WCCustomProperties.SET_UNENCODED_HTML_IN_SENDERROR) {
                            os.println(error.getUnencodedMessageAsHTML());
                        }
                        else {
                            os.println(error.getMessageAsHTML());
                        }// PM03788 End
                    }
                    else {
                        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                            logger.logp(Level.FINE, CLASS_NAME, "sendError", "display custom error text provided in the property");
                        }
                        os.println(WCCustomProperties.DISPLAY_TEXT_WHEN_NO_ERROR_PAGE_DEFINED);
                    }
                    reqState.removeAttribute("com.ibm.ws.webcontainer.AllowWriteFromE");
                }
                // PK23428 END
                // PI09474 End
            } else {
                try {
                    // first attempt to forward (this permits setting of
                    // headers)
                    // res.setStatus(200);
                    rd.forward(req, res);
                    if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
                        logger.exiting(CLASS_NAME, "sendError", "after forward");
                    return;
                } catch (IllegalStateException ise) {
                    // include the error handler
                    rd.include(req, res);
                    if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
                        logger.exiting(CLASS_NAME, "sendError", "after include");
                    return;
                }

            }
        } catch (Throwable th) {
            com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(th, CLASS_NAME + ".handleError", "912", this);
            // logger.logp(Level.SEVERE, CLASS_NAME,"sendError",
            // "Error.occurred.while.invoking.error.reporter", new Object[] {
            // error, th });

            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE)) {
                logger.logp(Level.FINE, CLASS_NAME, "sendError", "Error occurred while invoking error reporter");
                logger.logp(Level.FINE, CLASS_NAME, "sendError", "URL: " + req.getRequestURL());
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);

                if (th instanceof ServletException) {
                    DefaultErrorReporter.printFullStackTrace(pw, (ServletException) th);
                } else {
                    new TruncatableThrowable(th).printStackTrace(pw);
                }

                pw.flush();
                logger.logp(Level.FINE, CLASS_NAME, "sendError", "Full Exception dump of original error", sw.toString());
                sw = new StringWriter();
                pw = new PrintWriter(sw);
                if (th instanceof ServletException) {
                    DefaultErrorReporter.printFullStackTrace(pw, (ServletException) th);
                } else {
                    new TruncatableThrowable(th).printStackTrace(pw);
                }

                pw.flush();
                logger.logp(Level.FINE, CLASS_NAME, "sendError", "Full Exception dump of recursive error", sw.toString());
            }

            reportRecursiveError(req, res, error, new WebAppErrorReport(th));
        }

        try {
            // reset the error bean object
            req.setAttribute(ServletErrorReport.ATTRIBUTE_NAME, null);

            // 101639 reset the jsp exception object
            req.setAttribute("javax.servlet.jsp.jspException", null);
        } catch (Throwable th) {
            /* ignore */
            com.ibm.wsspi.webcontainer.util.FFDCWrapper.processException(th, CLASS_NAME + ".handleError", "961", this);
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINE))
            logger.exiting(CLASS_NAME, "sendError");

    }
579682
public void fail(String requestId) throws TException
    {
        int index = this.requestedMap.remove(requestId);
        DRPCInvocationsClient client = this.clients.get(index);
        client.failRequest(requestId);
    }
323525
private static synchronized void createStream(Http2Connection conn, int streamId) throws Http2Exception {
        conn.local().createStream(streamId, false);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Stream created streamId: {}", streamId);
        }
    }
1168510
@Override
	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {

		if (cause instanceof TransportException) {
			notifyAllChannelsOfErrorAndClose(cause);
		}
		else {
			final SocketAddress remoteAddr = ctx.channel().remoteAddress();

			final TransportException tex;

			// Improve on the connection reset by peer error message
			if (cause instanceof IOException
					&& cause.getMessage().equals("Connection reset by peer")) {

				tex = new RemoteTransportException(
						"Lost connection to task manager '" + remoteAddr + "'. This indicates "
								+ "that the remote task manager was lost.", remoteAddr, cause);
			}
			else {
				SocketAddress localAddr = ctx.channel().localAddress();
				tex = new LocalTransportException(
					String.format("%s (connection to '%s')", cause.getMessage(), remoteAddr),
					localAddr,
					cause);
			}

			notifyAllChannelsOfErrorAndClose(tex);
		}
	}
239848
@Override
    public void error(VirtualConnection vc, TCPWriteRequestContext wsc, IOException ioe) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "error, vc=" + getVCHash());
        }
        // Nothing else needs to be done here. Report error up the chain.
        this.asyncBytesToWrite = 0L;
        this.callback.error(vc, this, ioe);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "error");
        }
    }
9934
public void error(VirtualConnection vc, Throwable t) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "error() called: " + vc);
        }
        // can't do anything with a null VC
        if (null == vc) {
            return;
        }
        Object o = vc.getStateMap().get(CallbackIDs.CALLBACK_HTTPICL);
        if (null == o) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "ERROR: null ICL in error()");
            }
            return;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Error occurring while purging body: " + t);
        }
        // close the connection
        ((HttpInboundLink) o).close(vc, (Exception) t);
    }
327986
function StreamHandler(host, port, delimiter) {
	events.EventEmitter.call(this);

	var self = this;
	self.delimiter = delimiter || "\r\n";
	self.host      = host;
	self.port      = port;

	self.buffer    = '';

	self.conn = net.createConnection(self.port, self.host);
	self.conn.setEncoding("utf8");

	self.conn.on('error', function(err) {
		try {
			self.emit('error', 'Stream error: ' + err, err);
		} catch (e) {
			console.log('' + err);
		}
	});
	self.conn.on('data', function(data) {
		self.conn.pause();
		self.buffer += data;
		if (self.buffer.match(/\n/)) {
			var arr = self.buffer.split(self.delimiter);
			//Everything except the last one
			for(var i = 0; i < arr.length - 1; i++) {
				self.emit('line', arr[i]);
			}
			self.buffer = arr[arr.length - 1];
		}
		if (self.conn.readyState == 'open') {
			self.conn.resume();
		}
	});
	self.conn.on('close', function(had_error) {
		if (!had_error && self.buffer.length > 0) {
			self.emit('line', self.buffer);
		}
	});
}
1210565
@Override
    protected final void onStreamError(ChannelHandlerContext ctx, boolean outbound, Throwable cause,
                                 Http2Exception.StreamException streamException) {
        int streamId = streamException.streamId();
        Http2Stream connectionStream = connection().stream(streamId);
        if (connectionStream == null) {
            onHttp2UnknownStreamError(ctx, cause, streamException);
            // Write a RST_STREAM
            super.onStreamError(ctx, outbound, cause, streamException);
            return;
        }

        Http2FrameStream stream = connectionStream.getProperty(streamKey);
        if (stream == null) {
            LOG.warn("Stream exception thrown without stream object attached.", cause);
            // Write a RST_STREAM
            super.onStreamError(ctx, outbound, cause, streamException);
            return;
        }

        if (!outbound) {
            // We only forward non outbound errors as outbound errors will already be reflected by failing the promise.
            onHttp2FrameStreamException(ctx, new Http2FrameStreamException(stream, streamException.error(), cause));
        }
    }
1167878
private void sendAlert(byte level, byte description) {
        // the connectionState cannot be cs_START
        if (connectionState >= cs_CLOSED) {
            return;
        }

        // For initial handshaking, don't send alert message to peer if
        // handshaker has not started.
        if (connectionState == cs_HANDSHAKE &&
            (handshaker == null || !handshaker.started())) {
            return;
        }

        EngineOutputRecord r = new EngineOutputRecord(Record.ct_alert, this);
        r.setVersion(protocolVersion);

        boolean useDebug = debug != null && Debug.isOn("ssl");
        if (useDebug) {
            synchronized (System.out) {
                System.out.print(threadName());
                System.out.print(", SEND " + protocolVersion + " ALERT:  ");
                if (level == Alerts.alert_fatal) {
                    System.out.print("fatal, ");
                } else if (level == Alerts.alert_warning) {
                    System.out.print("warning, ");
                } else {
                    System.out.print("<level = " + (0x0ff & level) + ">, ");
                }
                System.out.println("description = "
                        + Alerts.alertDescription(description));
            }
        }

        r.write(level);
        r.write(description);
        try {
            writeRecord(r);
        } catch (IOException e) {
            if (useDebug) {
                System.out.println(threadName() +
                    ", Exception sending alert: " + e);
            }
        }
    }