Merge pull request #12734 from artem-barysh-dev/fix-snmp
SNMP: fix request sending failure
This commit is contained in:
commit
49f2a071c4
@ -1242,8 +1242,10 @@ transport:
|
|||||||
snmp:
|
snmp:
|
||||||
# Enable/disable SNMP transport protocol
|
# Enable/disable SNMP transport protocol
|
||||||
enabled: "${SNMP_ENABLED:true}"
|
enabled: "${SNMP_ENABLED:true}"
|
||||||
# Snmp bind port
|
# SNMP bind address
|
||||||
bind_port: "${SNMP_BIND_PORT:1620}"
|
bind_address: "${SNMP_BIND_ADDRESS:0.0.0.0}"
|
||||||
|
# SNMP bind port. Zero (random) by default. When using SNMP TRAPs - make sure to specify some static value, e.g. 1620
|
||||||
|
bind_port: "${SNMP_BIND_PORT:0}"
|
||||||
response_processing:
|
response_processing:
|
||||||
# parallelism level for executor (workStealingPool) that is responsible for handling responses from SNMP devices
|
# parallelism level for executor (workStealingPool) that is responsible for handling responses from SNMP devices
|
||||||
parallelism_level: "${SNMP_RESPONSE_PROCESSING_PARALLELISM_LEVEL:4}"
|
parallelism_level: "${SNMP_RESPONSE_PROCESSING_PARALLELISM_LEVEL:4}"
|
||||||
|
|||||||
@ -67,6 +67,7 @@ import org.thingsboard.server.transport.snmp.session.DeviceSessionContext;
|
|||||||
import org.thingsboard.server.transport.snmp.session.ScheduledTask;
|
import org.thingsboard.server.transport.snmp.session.ScheduledTask;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -97,8 +98,10 @@ public class SnmpTransportService implements TbTransportService, CommandResponde
|
|||||||
private final Map<SnmpCommunicationSpec, ResponseDataMapper> responseDataMappers = new EnumMap<>(SnmpCommunicationSpec.class);
|
private final Map<SnmpCommunicationSpec, ResponseDataMapper> responseDataMappers = new EnumMap<>(SnmpCommunicationSpec.class);
|
||||||
private final Map<SnmpCommunicationSpec, ResponseProcessor> responseProcessors = new EnumMap<>(SnmpCommunicationSpec.class);
|
private final Map<SnmpCommunicationSpec, ResponseProcessor> responseProcessors = new EnumMap<>(SnmpCommunicationSpec.class);
|
||||||
|
|
||||||
@Value("${transport.snmp.bind_port:1620}")
|
@Value("${transport.snmp.bind_port:0}")
|
||||||
private Integer snmpBindPort;
|
private Integer snmpBindPort;
|
||||||
|
@Value("${transport.snmp.bind_address:0.0.0.0}")
|
||||||
|
private String snmpBindAddress;
|
||||||
@Value("${transport.snmp.response_processing.parallelism_level:4}")
|
@Value("${transport.snmp.response_processing.parallelism_level:4}")
|
||||||
private int responseProcessingThreadPoolSize;
|
private int responseProcessingThreadPoolSize;
|
||||||
@Value("${transport.snmp.scheduler_thread_pool_size:4}")
|
@Value("${transport.snmp.scheduler_thread_pool_size:4}")
|
||||||
@ -134,10 +137,10 @@ public class SnmpTransportService implements TbTransportService, CommandResponde
|
|||||||
TransportMapping<?> transportMapping;
|
TransportMapping<?> transportMapping;
|
||||||
switch (snmpUnderlyingProtocol) {
|
switch (snmpUnderlyingProtocol) {
|
||||||
case "udp":
|
case "udp":
|
||||||
transportMapping = new DefaultUdpTransportMapping(new UdpAddress(snmpBindPort));
|
transportMapping = new DefaultUdpTransportMapping(new UdpAddress(InetAddress.getByName(snmpBindAddress), snmpBindPort));
|
||||||
break;
|
break;
|
||||||
case "tcp":
|
case "tcp":
|
||||||
transportMapping = new DefaultTcpTransportMapping(new TcpAddress(snmpBindPort));
|
transportMapping = new DefaultTcpTransportMapping(new TcpAddress(InetAddress.getByName(snmpBindAddress), snmpBindPort));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Underlying protocol " + snmpUnderlyingProtocol + " for SNMP is not supported");
|
throw new IllegalArgumentException("Underlying protocol " + snmpUnderlyingProtocol + " for SNMP is not supported");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user