public void onResponse(ResponseEvent event) { // Always cancel async request when response has been received // otherwise a memory leak is created! Not canceling a request // immediately can be useful when sending a request to a broadcast address. ((Snmp)event.getSource()).cancel(event.getRequest(), this); // check for valid response if (event.getRequest() == null || event.getResponse() == null) { // ignore null requests/responses LOG.debug("Received invalid SNMP event. Request: " + event.getRequest() + " / Response: " + event.getResponse()); return; } PDU pdu = event.getResponse(); processPDU(pdu); }
public void onResponse(ResponseEvent event) { // Always cancel async request when response has been received // otherwise a memory leak is created! Not canceling a request // immediately can be useful when sending a request to a broadcast // address. ((Snmp)event.getSource()).cancel(event.getRequest(), this); // check for valid response if (event.getRequest() == null || event.getResponse() == null) { // ignore null requests/responses logger.debug("Received invalid snmp event. Request: {} / Response: {}", event.getRequest(), event.getResponse()); return; } // now prepare the message and send it sendSnmpDataMessage(event.getRequest(), event.getResponse()); }
@Override public void onResponse(ResponseEvent responseEvent) { // need to cancel the request here otherwise SNMP4J Keeps it around forever... go figure m_session.cancel(responseEvent.getRequest(), this); // Check to see if we got an interrupted exception if (responseEvent.getError() instanceof InterruptedException) { LOG.debug("Interruption event. We have probably tried to close the session due to an error", responseEvent.getError()); // Check to see if the response is null, indicating a timeout } else if (responseEvent.getResponse() == null) { handleTimeout(getName()+": snmpTimeoutError for: " + getAddress()); // Check to see if we got any kind of error } else if (responseEvent.getError() != null){ handleError(getName()+": snmpInternalError: " + responseEvent.getError() + " for: " + getAddress(), responseEvent.getError()); // If we have a PDU in the response, process it } else { try { processResponse(responseEvent.getResponse()); } catch (final SnmpException e) { handleFatalError(e); } } }
@Override public void onResponse(ResponseEvent responseEvent) { // need to cancel the request here otherwise SNMP4J Keeps it around forever... go figure m_session.cancel(responseEvent.getRequest(), this); // Check to see if we got an interrupted exception if (responseEvent.getError() instanceof InterruptedException) { LOG.debug("Interruption event. We have probably tried to close the session due to an error", responseEvent.getError()); // Check to see if the response is null, indicating a timeout } else if (responseEvent.getResponse() == null) { handleTimeout(getName()+": snmpTimeoutError for: " + getAddress()); // Check to see if we got any kind of error } else if (responseEvent.getError() != null){ handleError(getName()+": snmpInternalError: " + responseEvent.getError() + " for: " + getAddress(), responseEvent.getError()); // If we have a PDU in the response, process it } else { try { processResponse(responseEvent.getResponse()); } catch (final SnmpException e) { handleFatalError(e); } } }
public void onResponse(ResponseEvent responseEvent) { // need to cancel the request here otherwise SNMP4J Keeps it around forever... go figure m_session.cancel(responseEvent.getRequest(), this); // Check to see if we got an interrupted exception if (responseEvent.getError() instanceof InterruptedException) { if (log().isDebugEnabled()) { log().debug("Interruption event. We have probably tried to close the session due to an error: " + responseEvent.getError(), responseEvent.getError()); } // Check to see if the response is null, indicating a timeout } else if (responseEvent.getResponse() == null) { handleTimeout(getName()+": snmpTimeoutError for: " + getAddress()); // Check to see if we got any kind of error } else if (responseEvent.getError() != null){ handleError(getName()+": snmpInternalError: " + responseEvent.getError() + " for: " + getAddress(), responseEvent.getError()); // If we have a PDU in the response, process it } else { processResponse(responseEvent.getResponse()); } }