Skip to content

Commit 92c5c98

Browse files
authored
Merge branch 'main' into development
2 parents 3d958b2 + 2cc2505 commit 92c5c98

File tree

6 files changed

+186
-34
lines changed

6 files changed

+186
-34
lines changed

PROTOCOLS.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Supported Protocols and Management Interfaces
2+
3+
This document summarizes the client-facing and management/admin protocols supported by the Maps Messaging Server, with code and configuration pointers. All ports are configurable; values below reflect the defaults in the provided config files.
4+
5+
6+
## Discovery and bootstrapping
7+
- Protocols are discovered via ServiceLoader:
8+
- Protocol implementations: src/main/java/io/mapsmessaging/network/protocol/impl/**/* (registered via ProtocolImplFactory)
9+
- Endpoint/transport servers: src/main/java/io/mapsmessaging/network/io/impl/**/* (registered via EndPointServerFactory)
10+
- Feature flags gate loading (see SubSystemManager and NetworkManager):
11+
- Protocols: feature "protocols.<name>" (e.g., protocols.mqtt, protocols.nats)
12+
- Network transports: feature "network.<name>" (e.g., network.tcp, network.udp)
13+
- YAML configuration drives listeners and defaults:
14+
- Network endpoints: src/main/resources/NetworkManager.yaml (and NetworkManagerDocker.yaml)
15+
- REST API: src/main/resources/RestApi.yaml
16+
- JMX, system topics, etc.: src/main/resources/MessageDaemon.yaml
17+
- Auth: src/main/resources/AuthManager.yaml
18+
19+
20+
## Client-facing protocols
21+
22+
### MQTT v3.1.1
23+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/mqtt/*
24+
- Factory: MQTTProtocolFactory.java (declares "MQTT version 3.1.1")
25+
- Default endpoints (NetworkManager.yaml):
26+
- tcp://:::1883/ (protocol: mqtt)
27+
- ssl://0.0.0.0:1892/ (protocols: mqtt, ws) — MQTT over WebSocket supported here
28+
- Authentication: username/password (Connect), enforced via AuthManager (JAAS). TLS optional.
29+
30+
### MQTT v5.0
31+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/mqtt5/*
32+
- Factory: MQTT5ProtocolFactory.java (declares "MQTT version 5.0")
33+
- Endpoints: same listener types as MQTT 3.1.1 when configured for mqtt in YAML.
34+
- Authentication: username/password and optional enhanced auth; TLS optional.
35+
36+
### AMQP 1.0
37+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/amqp/*
38+
- Uses Apache Qpid Proton-J (pom.xml: org.apache.qpid:proton-j)
39+
- Factory: AMQPProtocolFactory.java
40+
- Default endpoints (NetworkManager.yaml):
41+
- tcp://0.0.0.0:5672/ (protocol: amqp)
42+
- ssl://0.0.0.0:5692/ (protocol: amqp)
43+
- Authentication: SASL (PLAIN/ANONYMOUS etc.) via Proton; per-endpoint SASL config supported (EndPointServerConfigDTO.saslConfig). TLS optional.
44+
- WebSocket subprotocol: "amqp" when ws/wss is enabled (see WebSocket section below).
45+
46+
### STOMP 1.1/1.2
47+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/stomp/*
48+
- Supported versions: 1.1 and 1.2 (BaseConnectListener.java)
49+
- Factory: StompProtocolFactory.java
50+
- Default endpoints (NetworkManager.yaml):
51+
- tcp://0.0.0.0:8674/ (protocols: stomp, ws)
52+
- ssl://0.0.0.0:8695/ (protocols: stomp, wss)
53+
- Authentication: login/passcode headers (anonymous if not supplied), enforced via AuthManager. TLS optional.
54+
- WebSocket subprotocols: v10.stomp, v11.stomp, v12.stomp.
55+
56+
### NATS (v2.0)
57+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/nats/*
58+
- Factory: NatsProtocolFactory.java
59+
- getVersion() returns "2.0"
60+
- Default endpoint (NetworkManager.yaml):
61+
- tcp://0.0.0.0:4222/ (protocol: nats)
62+
- Authentication: optional user/pass in CONNECT; enforced via AuthManager. TLS optional.
63+
64+
### CoAP (RFC 7252/7641/7959)
65+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/coap/*
66+
- Factory: CoapProtocolFactory.java (notes RFCs)
67+
- Default endpoints (NetworkManager.yaml):
68+
- udp://0.0.0.0:5683/ (protocol: coap)
69+
- dtls://0.0.0.0:5684/ (protocol: coap)
70+
- Transport/auth: UDP and DTLS supported; DTLS configurable in YAML.
71+
72+
### MQTT-SN v1.2 and v2.0
73+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/mqtt_sn/* (v1_2, v2_0)
74+
- Factory: MQTT_SNProtocolFactory.java
75+
- Interface manager: MQTTSNInterfaceManager.java (selects v1.2 or v2.0 based on CONNECT)
76+
- Default endpoints (NetworkManager.yaml):
77+
- udp://0.0.0.0:1884/ (protocol: mqtt-sn)
78+
- dtls://0.0.0.0:1886/ (protocol: mqtt-sn)
79+
- Transport/auth: UDP/DTLS; username/password optional; DTLS configurable.
80+
81+
### WebSocket (RFC 6455, encapsulation)
82+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/websockets/*
83+
- Factory: WebSocketProtocolFactory.java; handshake in Connecting.java
84+
- Subprotocols supported (when allowed by endpoint protocols): mqtt, amqp, v10.stomp, v11.stomp, v12.stomp
85+
- Endpoints: enabled when endpoint "protocols" includes ws (or wss). Examples in NetworkManager.yaml:
86+
- ssl://0.0.0.0:1892/ (protocols: mqtt, ws)
87+
- tcp://0.0.0.0:8674/ (protocols: stomp, ws)
88+
89+
### LoRaWAN Semtech UDP gateway
90+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/semtech/*
91+
- Factory: SemTechProtocolFactory.java
92+
- Config DTO: dto/rest/config/protocol/impl/SemtechConfigDTO.java (maps inbound/outbound/status topics)
93+
- Endpoint: UDP port is user-configurable (commonly 1700). Not enabled by default in NetworkManager.yaml; add a UDP endpoint with protocol: semtech.
94+
95+
### NMEA-0183 (serial)
96+
- Implementation: src/main/java/io/mapsmessaging/network/protocol/impl/nmea/*
97+
- Example (commented) in NetworkManager.yaml shows serial usage:
98+
- serial://ttyUSB0,9600,8,N,1/ with protocol: NMEA-0183
99+
100+
101+
## Transports / listeners
102+
- TCP: src/main/java/io/mapsmessaging/network/io/impl/tcp/* (TCPEndPointServerFactory)
103+
- SSL/TLS: src/main/java/io/mapsmessaging/network/io/impl/ssl/*
104+
- UDP: src/main/java/io/mapsmessaging/network/io/impl/udp/*
105+
- DTLS: src/main/java/io/mapsmessaging/network/io/impl/dtls/*
106+
- Serial: src/main/java/io/mapsmessaging/network/io/impl/serial/*
107+
- LoRa: src/main/java/io/mapsmessaging/network/io/impl/lora/*
108+
- Proxy Protocol: EndPointConfigDTO supports proxyProtocolMode and allowedProxyHosts
109+
110+
111+
## Default endpoints/ports (from NetworkManager.yaml)
112+
- MQTT: tcp://:::1883/ (mqtt)
113+
- MQTT + WebSocket (TLS): ssl://0.0.0.0:1892/ (mqtt, ws)
114+
- NATS: tcp://0.0.0.0:4222/ (nats)
115+
- STOMP: tcp://0.0.0.0:8674/ (stomp, ws)
116+
- STOMP TLS: ssl://0.0.0.0:8695/ (stomp, wss)
117+
- AMQP: tcp://0.0.0.0:5672/ (amqp)
118+
- AMQP TLS: ssl://0.0.0.0:5692/ (amqp)
119+
- MQTT-SN: udp://0.0.0.0:1884/ (mqtt-sn)
120+
- MQTT-SN DTLS: dtls://0.0.0.0:1886/ (mqtt-sn)
121+
- CoAP: udp://0.0.0.0:5683/ (coap)
122+
- CoAP DTLS: dtls://0.0.0.0:5684/ (coap)
123+
- Docker example (NetworkManagerDocker.yaml): tcp://0.0.0.0:9000/ (protocol: all → amqp, mqtt, stomp, nats, ws)
124+
125+
126+
## Authentication
127+
- Central manager: src/main/java/io/mapsmessaging/auth/AuthManager.java; config in src/main/resources/AuthManager.yaml
128+
- JAAS-based; requires -Djava.security.auth.login.config=<path> at runtime when authenticationEnabled=true
129+
- On first boot, creates initial users (admin/user) with random passwords under MAPS_DATA/.security
130+
- Protocol-level:
131+
- MQTT 3/5: username/password in CONNECT; v5 supports enhanced auth (AuthenticationContext)
132+
- STOMP: login/passcode headers; if absent, attempts anonymous
133+
- NATS: user/pass in CONNECT
134+
- AMQP: SASL via Proton; per-endpoint SASL (EndPointServerConfigDTO.saslConfig)
135+
- TLS/DTLS available for endpoints (NetworkManager.yaml → global.security.tls/dtls), with optional client-certificate requirements
136+
- Proxy Protocol support at endpoint level (EndPointConfigDTO: proxyProtocolMode, allowedProxyHosts)
137+
138+
139+
## Management and administration
140+
- REST API (Jersey/Grizzly)
141+
- Base path: /api/v1 (src/main/java/io/mapsmessaging/rest/api/Constants.java)
142+
- Config: src/main/resources/RestApi.yaml; code: src/main/java/io/mapsmessaging/rest/RestApiServerManager.java
143+
- Default: http://0.0.0.0:8080 (TLS optional via RestApi.yaml)
144+
- Swagger/OpenAPI enabled by default; endpoints registered in MapsRestServerApi.java and other resources under io.mapsmessaging.rest.api.impl.*
145+
- Health endpoints:
146+
- /health (plain text): src/main/java/io/mapsmessaging/rest/api/impl/ConsulHealth.java
147+
- /api/v1/server/health and /api/v1/server/status (JSON): ServerDetailsApi.java
148+
- Other: /api/v1/ping, plus auth/destination/interface/schema/device/logging/ML endpoints when enabled
149+
- JMX
150+
- Enabled by default (MessageDaemon.yaml: EnableJMX: true). Beans under io.mapsmessaging.admin, network.*.jmx, etc.
151+
- Jolokia (JMX over HTTP)
152+
- Optional bridge; default disabled (src/main/resources/jolokia.yaml, default port 8778)
153+
- Metrics
154+
- Exposed via JMX; a Prometheus JMX exporter mapping is provided at src/main/resources/prometheus_config.yml
155+
- Discovery/Registration
156+
- Consul integration registers endpoint metadata (MessageDaemon.buildMetaData; ConsulManagerFactory)
157+
158+
159+
## Key code entry points
160+
- Bootstrap: src/main/java/io/mapsmessaging/MessageDaemon.java
161+
- Subsystems: src/main/java/io/mapsmessaging/SubSystemManager.java
162+
- Network manager: src/main/java/io/mapsmessaging/network/NetworkManager.java
163+
- Endpoint URL parsing: src/main/java/io/mapsmessaging/network/EndPointURL.java
164+
- EndPoint config packing/unpacking: src/main/java/io/mapsmessaging/config/network/EndPointConfigFactory.java
165+
166+
167+
## Configuration files
168+
- Network endpoints and protocol defaults: src/main/resources/NetworkManager.yaml
169+
- Docker example: src/main/resources/NetworkManagerDocker.yaml
170+
- REST API: src/main/resources/RestApi.yaml
171+
- Message daemon (JMX, system topics, compression, etc.): src/main/resources/MessageDaemon.yaml
172+
- Authentication: src/main/resources/AuthManager.yaml
173+
- Jolokia: src/main/resources/jolokia.yaml
174+
- Prometheus JMX exporter mapping: src/main/resources/prometheus_config.yml

src/main/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ EXPOSE 9000/tcp 8080/tcp 8778/tcp 4222/tcp 1883/tcp \
5757

5858
VOLUME /data
5959

60-
CMD su -c "ulimit -n 100000 && ./maps-%%MAPS_VERSION%%/bin/startDocker.sh" messaginguser
60+
CMD su -c "ulimit -n 100000 && ./maps-%%MAPS_VERSION%%/bin/startDocker.sh" messaginguser

src/main/docker/arm/Dockerfile

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,15 @@
11
# syntax=docker/dockerfile:1
22

3-
#
43
#
54
# Copyright [ 2020 - 2024 ] [Matthew Buckton]
65
# Copyright [ 2024 - 2025 ] [Maps Messaging B.V.]
76
#
8-
# Licensed under the Apache License, Version 2.0 (the "License");
9-
# you may not use this file except in compliance with the License.
10-
# You may obtain a copy of the License at
11-
#
12-
# http://www.apache.org/licenses/LICENSE-2.0
13-
#
14-
# Unless required by applicable law or agreed to in writing, software
15-
# distributed under the License is distributed on an "AS IS" BASIS,
16-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17-
# See the License for the specific language governing permissions and
18-
# limitations under the License.
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# http://www.apache.org/licenses/LICENSE-2.0
199
#
2010

21-
#----------------------------------------------------------------------------------------------
22-
# Base: Alpine (ARM64)
23-
#----------------------------------------------------------------------------------------------
24-
FROM arm64v8/alpine:3.22.1
11+
FROM alpine:3.22.1
2512

26-
#----------------------------------------------------------------------------------------------
27-
# Locale + Java home + PATH
28-
#----------------------------------------------------------------------------------------------
2913
ENV LANG=en_US.UTF-8 \
3014
LANGUAGE=en_US:en \
3115
LC_ALL=en_US.UTF-8 \
@@ -84,11 +68,4 @@ EXPOSE 9000/tcp 8080/tcp 8778/tcp 4222/tcp 1883/tcp \
8468
#----------------------------------------------------------------------------------------------
8569
VOLUME /data
8670

87-
#----------------------------------------------------------------------------------------------
88-
# Run as non-root from install dir
89-
#----------------------------------------------------------------------------------------------
90-
USER messaginguser
91-
WORKDIR /maps-%%MAPS_VERSION%%
92-
93-
# Increase file descriptors and start
94-
CMD sh -lc 'ulimit -n 100000 && ./bin/startDocker.sh'
71+
CMD su -c "ulimit -n 100000 && ./maps-%%MAPS_VERSION%%/bin/startDocker.sh" messaginguser

src/main/java/io/mapsmessaging/network/protocol/impl/satellite/gateway/protocol/SatelliteGatewayProtocol.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public SatelliteGatewayProtocol(@NonNull @NotNull EndPoint endPoint, @NotNull @N
127127
}
128128
namespacePath = config.getNamespace();
129129
if(namespacePath == null || namespacePath.isEmpty()){
130-
namespacePath = "/incoming/{mailboxId}/{deviceId}";
130+
namespacePath = "/incoming/{mailboxId}/{deviceId}/{sin}";
131131
}
132132
namespacePath = namespacePath.replace("{deviceId}", primeId);
133133
namespacePath = namespacePath.replace("{mailboxId}", config.getMailboxId());
@@ -328,7 +328,10 @@ public void handleIncomingMessage(MessageData message) throws ExecutionException
328328
System.arraycopy(raw, 2, tmp, 0, tmp.length);
329329
SatelliteMessage satelliteMessage = new SatelliteMessage(sin, tmp);
330330
if(satelliteMessage.isRaw()){
331-
publishMessage(satelliteMessage.getMessage(), namespacePath, null);
331+
String path = namespacePath;
332+
int val = sin & 0xff;
333+
path = path.replace("{sin}", String.valueOf(val));
334+
publishMessage(satelliteMessage.getMessage(), path, null);
332335
}
333336
else {
334337
satelliteMessage = messageRebuilder.rebuild(satelliteMessage);

src/main/java/io/mapsmessaging/stats/ServerStatsPopulator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static ServerStats collect(String serverId, String serverName, String lic
2626
stats.setServerName(serverName);
2727
stats.setServerId(serverId);
2828
stats.setLicenseId(licenseId);
29-
stats.setTimestamp(System.currentTimeMillis() / 1000L);
29+
stats.setTimestamp(System.currentTimeMillis());
3030

3131
stats.setVersion(buildVersionInfo(serverVersion));
3232
stats.setMemory(buildMemoryStats());

src/main/scripts/startDocker.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,4 @@ java -classpath $CLASSPATH $JAVA_OPTS \
7070
-DConsulToken="${CONSUL_TOKEN}" \
7171
-Djava.security.auth.login.config="${MAPS_CONF}/jaasAuth.config" \
7272
-DMAPS_HOME="${MAPS_HOME}" \
73-
io.mapsmessaging.MessageDaemon
74-
75-
73+
io.mapsmessaging.MessageDaemon

0 commit comments

Comments
 (0)