Commit 522d392777cb41453a46fd820eee125dfe06072f
1 parent
96d344fa
RPC and MQTT packet size bug fixes
Showing
4 changed files
with
11 additions
and
38 deletions
... | ... | @@ -54,40 +54,4 @@ |
54 | 54 | </dependency> |
55 | 55 | </dependencies> |
56 | 56 | |
57 | - <build> | |
58 | - <plugins> | |
59 | - <plugin> | |
60 | - <groupId>org.apache.maven.plugins</groupId> | |
61 | - <artifactId>maven-shade-plugin</artifactId> | |
62 | - <executions> | |
63 | - <execution> | |
64 | - <phase>package</phase> | |
65 | - <goals> | |
66 | - <goal>shade</goal> | |
67 | - </goals> | |
68 | - <configuration> | |
69 | - <filters> | |
70 | - <filter> | |
71 | - <artifact>*:*</artifact> | |
72 | - <excludes> | |
73 | - <exclude>META-INF/*.SF</exclude> | |
74 | - <exclude>META-INF/*.DSA</exclude> | |
75 | - <exclude>META-INF/*.RSA</exclude> | |
76 | - </excludes> | |
77 | - </filter> | |
78 | - </filters> | |
79 | - <transformers> | |
80 | - <transformer | |
81 | - implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | |
82 | - <manifestEntries> | |
83 | - <Main-Class>org.thingsboard.client.tools.MqttStressTestTool</Main-Class> | |
84 | - </manifestEntries> | |
85 | - </transformer> | |
86 | - </transformers> | |
87 | - </configuration> | |
88 | - </execution> | |
89 | - </executions> | |
90 | - </plugin> | |
91 | - </plugins> | |
92 | - </build> | |
93 | 57 | </project> | ... | ... |
... | ... | @@ -27,6 +27,7 @@ import org.springframework.http.client.support.HttpRequestWrapper; |
27 | 27 | import org.springframework.web.client.HttpClientErrorException; |
28 | 28 | import org.springframework.web.client.RestTemplate; |
29 | 29 | import org.thingsboard.server.common.data.Device; |
30 | +import org.thingsboard.server.common.data.id.CustomerId; | |
30 | 31 | import org.thingsboard.server.common.data.id.DeviceId; |
31 | 32 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
32 | 33 | |
... | ... | @@ -76,6 +77,12 @@ public class RestClient implements ClientHttpRequestInterceptor { |
76 | 77 | return restTemplate.postForEntity(baseURL + "/api/device", device, Device.class).getBody(); |
77 | 78 | } |
78 | 79 | |
80 | + | |
81 | + public Device assignDevice(CustomerId customerId, DeviceId deviceId) { | |
82 | + return restTemplate.postForEntity(baseURL + "/api/customer/{customerId}/device/{deviceId}", null, Device.class, | |
83 | + customerId.toString(), deviceId.toString()).getBody(); | |
84 | + } | |
85 | + | |
79 | 86 | public DeviceCredentials getCredentials(DeviceId id) { |
80 | 87 | return restTemplate.getForEntity(baseURL + "/api/device/" + id.getId().toString() + "/credentials", DeviceCredentials.class).getBody(); |
81 | 88 | } | ... | ... |
... | ... | @@ -40,6 +40,8 @@ import java.security.cert.CertificateException; |
40 | 40 | */ |
41 | 41 | public class MqttTransportServerInitializer extends ChannelInitializer<SocketChannel> { |
42 | 42 | |
43 | + private static final int MAX_PAYLOAD_SIZE = 64 * 1024 * 1024; | |
44 | + | |
43 | 45 | private final SessionMsgProcessor processor; |
44 | 46 | private final DeviceService deviceService; |
45 | 47 | private final DeviceAuthService authService; |
... | ... | @@ -63,7 +65,7 @@ public class MqttTransportServerInitializer extends ChannelInitializer<SocketCha |
63 | 65 | sslHandler = sslHandlerProvider.getSslHandler(); |
64 | 66 | pipeline.addLast(sslHandler); |
65 | 67 | } |
66 | - pipeline.addLast("decoder", new MqttDecoder()); | |
68 | + pipeline.addLast("decoder", new MqttDecoder(MAX_PAYLOAD_SIZE)); | |
67 | 69 | pipeline.addLast("encoder", MqttEncoder.INSTANCE); |
68 | 70 | |
69 | 71 | MqttTransportHandler handler = new MqttTransportHandler(processor, deviceService, authService, adaptor, sslHandler); | ... | ... |
... | ... | @@ -134,7 +134,7 @@ public class GatewaySessionCtx { |
134 | 134 | JsonObject jsonObj = json.getAsJsonObject(); |
135 | 135 | String deviceName = checkDeviceConnected(jsonObj.get("device").getAsString()); |
136 | 136 | Integer requestId = jsonObj.get("id").getAsInt(); |
137 | - String data = jsonObj.get("data").getAsString(); | |
137 | + String data = jsonObj.get("data").toString(); | |
138 | 138 | GatewayDeviceSessionCtx deviceSessionCtx = devices.get(deviceName); |
139 | 139 | processor.process(new BasicToDeviceActorSessionMsg(deviceSessionCtx.getDevice(), |
140 | 140 | new BasicAdaptorToSessionActorMsg(deviceSessionCtx, new ToDeviceRpcResponseMsg(requestId, data)))); | ... | ... |