response.sendError(404, "invalid path"); return null; response.sendError(404, "invalid path"); return null; + "(expected '" + serverId + "', received '" + ids[0] + "')."); response.sendError(404, "server ID mismatch"); return null; response.sendError(500, "no videobridge"); return null; response.sendError(403, authFailed); return null; response.sendError(403, authFailed); return null; if (!endpoint.acceptWebSocket(pwd)) response.sendError(403, authFailed); return null;
private void sendError(int statusCode, String message, ServletUpgradeResponse resp) { try { resp.sendError(statusCode, message); } catch (IOException e) { log.error("sendError ['{}', '{}'] -> error", statusCode, message, e); throw new RuntimeException(e); } } }
private Object createWebSocketAdapter(ServletUpgradeRequest request, ServletUpgradeResponse response) { GenericRequestHandler handler = (GenericRequestHandler)request.getServletAttribute( GenericRequestHandler.class.getName()); request.setServletAttribute(GenericRequestHandler.class.getName(), null); Object result = handler.createWebSocketAdapter(request, response); if ( null == result ) { // Avoid 503 response. try { response.sendError(404, "Not Found"); } catch ( IOException ex ) { throw new UncheckedIOException(ex); } } return result; } }
request.getRemotePort(), authRole, topic, e.getMessage()); try { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Failed to authenticate"); } catch (IOException e1) { log.warn("[{}:{}] Failed to send error: {}", request.getRemoteAddr(), request.getRemotePort(), log.warn("[{}:{}] WebSocket Client [{}] is not authorized on topic {}", request.getRemoteAddr(), request.getRemotePort(), authRole, topic); response.sendError(HttpServletResponse.SC_FORBIDDEN, "Not authorized"); return false; request.getRemoteAddr(), request.getRemotePort(), authRole, topic, e.getMessage()); try { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Server error"); } catch (IOException e1) { log.warn("[{}:{}] Failed to send error: {}", request.getRemoteAddr(), request.getRemotePort(),
public ProducerHandler(WebSocketService service, HttpServletRequest request, ServletUpgradeResponse response) { super(service, request, response); this.numMsgsSent = new LongAdder(); this.numBytesSent = new LongAdder(); this.numMsgsFailed = new LongAdder(); this.publishLatencyStatsUSec = new StatsBuckets(ENTRY_LATENCY_BUCKETS_USEC); if (!checkAuth(response)) { return; } try { this.producer = getProducerBuilder(service.getPulsarClient()).topic(topic.toString()).create(); if (!this.service.addProducer(this)) { log.warn("[{}:{}] Failed to add producer handler for topic {}", request.getRemoteAddr(), request.getRemotePort(), topic); } } catch (Exception e) { log.warn("[{}:{}] Failed in creating producer on topic {}: {}", request.getRemoteAddr(), request.getRemotePort(), topic, e.getMessage()); try { response.sendError(getErrorCode(e), getErrorMessage(e)); } catch (IOException e1) { log.warn("[{}:{}] Failed to send error: {}", request.getRemoteAddr(), request.getRemotePort(), e1.getMessage(), e1); } } }
sockresp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Endpoint Creation Failed"); return false;
request.getRemotePort(), subscription, topic, e); try { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to create reader: " + e.getMessage()); } catch (IOException e1) {
response.sendError(getErrorCode(e), getErrorMessage(e)); } catch (IOException e1) { log.warn("[{}:{}] Failed to send error: {}", request.getRemoteAddr(), request.getRemotePort(),
response.sendError(HttpStatus.BAD_REQUEST_400, "Unsupported websocket version specification"); return false;