Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions .github/workflows/functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ jobs:
needs: [check-changes, build-test-image]
if: needs.check-changes.outputs.should_run == 'true'
services:
mosquitto:
image: eclipse-mosquitto:1.6
ports:
- 1883:1883
- 9001:9001
postgres:
image: postgis/postgis:17-3.5-alpine
env:
Expand Down Expand Up @@ -126,11 +121,23 @@ jobs:
run: |
docker load --input /tmp/test-image.tar

- name: Start MQTTS broker
- name: Start MQTT + MQTTS brokers
run: |
sudo apt-get install -y mosquitto openssl
# Stop the systemd-launched mosquitto so we can run with our own
# config (mosquitto 2.0 defaults to allow_anonymous false, which
# breaks the test suite's assumption of an open broker).
sudo systemctl stop mosquitto || true

# Plain MQTT on 1883 — anonymous enabled
cat > /tmp/mosquitto-plain.conf << EOF
listener 1883
allow_anonymous true
EOF
mosquitto -c /tmp/mosquitto-plain.conf -d

# MQTTS on 8883 with self-signed certs
mkdir -p /tmp/mosquitto-mqtts
# Generate self-signed certs for MQTTS testing
openssl req -new -x509 -days 30 -nodes \
-keyout /tmp/mosquitto-mqtts/ca.key -out /tmp/mosquitto-mqtts/ca.crt \
-subj "/CN=MQTT Test CA" 2>/dev/null
Expand Down
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Fixed Issues
#1905 - TRoE: segfault (exit 139) connecting to TimescaleDB Cloud - added SSL support and fixed NULL pointer crash
#XXXX - Fixed crash under concurrent notification delivery by replacing thread-unsafe gethostbyname with getaddrinfo in orionldServerConnect
#XXXX - Fixed query of many large entities (cfreyfh - Carsten Freyh at Fraunhofer IKTS)
#XXXX - Wait for postgres instead of exiting after the first try - just like for mongo (1 try per second during 30 secs)
#XXXX - Fixed crash in relationship endpoint when no relations found (cfreyfh)
Expand Down
2 changes: 2 additions & 0 deletions doc/manuals-ld/installation-guide-centos7.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ sudo systemctl start mosquitto
sudo systemctl enable mosquitto
```

Note: Orion-LD's MQTT subscription support includes MQTT 5.0, which requires Mosquitto 2.0 or later. The EPEL package for CentOS 7 ships 1.4.x, so if you need MQTT 5.0 use the upstream repository from https://mosquitto.org.

### Fast-DDS (optional, for DDS support)

Fast-DDS is eProsima's implementation of the DDS (Data Distribution Service) standard. It enables Orion-LD to communicate with DDS-based systems.
Expand Down
2 changes: 2 additions & 0 deletions doc/manuals-ld/installation-guide-debian10.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ sudo systemctl start mosquitto
sudo systemctl enable mosquitto
```

Note: Orion-LD's MQTT subscription support includes MQTT 5.0, which requires Mosquitto 2.0 or later. The Debian 10 distro package ships 1.5.x, so if you need MQTT 5.0 use the upstream repository from https://mosquitto.org.

### Fast-DDS (optional, for DDS support)

Fast-DDS is eProsima's implementation of the DDS (Data Distribution Service) standard. It enables Orion-LD to communicate with DDS-based systems.
Expand Down
2 changes: 2 additions & 0 deletions doc/manuals-ld/installation-guide-debian9.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ sudo systemctl start mosquitto
sudo systemctl enable mosquitto
```

Note: Orion-LD's MQTT subscription support includes MQTT 5.0, which requires Mosquitto 2.0 or later. The Debian 9 distro package ships 1.4.x, so if you need MQTT 5.0 use the upstream repository from https://mosquitto.org.

### Fast-DDS (optional, for DDS support)

Fast-DDS is eProsima's implementation of the DDS (Data Distribution Service) standard. It enables Orion-LD to communicate with DDS-based systems.
Expand Down
6 changes: 4 additions & 2 deletions doc/manuals-ld/installation-guide-ubuntu-18.04.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,12 @@ If you wish to enable `mosquitto` to have it start automatically on system reboo
sudo systemctl enable mosquitto
```

### Postgres 12
Note: Orion-LD's MQTT subscription support includes MQTT 5.0, which requires Mosquitto 2.0 or later. The Ubuntu 18.04 distro package ships 1.4.x, so if you need MQTT 5.0 use the upstream PPA: `sudo add-apt-repository ppa:mosquitto-dev/mosquitto-ppa`.

### Postgres 17
Postgres is used as database for the Temporal Evolution of entities

#### Install Postgres 12
#### Install Postgres 17
```bash
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
Expand Down
6 changes: 4 additions & 2 deletions doc/manuals-ld/installation-guide-ubuntu-20.04.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,12 @@ If you wish to enable `mosquitto` to have it start automatically on system reboo
sudo systemctl enable mosquitto
```

### Postgres 12
Note: Orion-LD's MQTT subscription support includes MQTT 5.0, which requires Mosquitto 2.0 or later. The Ubuntu 20.04 distro package ships 1.6.x, so if you need MQTT 5.0 use the upstream PPA: `sudo add-apt-repository ppa:mosquitto-dev/mosquitto-ppa`.

### Postgres 17
Postgres is used as database for the Temporal Evolution of entities

#### Install Postgres 12
#### Install Postgres 17
```bash
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
Expand Down
4 changes: 3 additions & 1 deletion doc/manuals-ld/installation-guide-ubuntu-22.04.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ If you wish to enable `mosquitto` to have it start automatically on system reboo
sudo systemctl enable mosquitto
```

### Postgres 12
Note: Orion-LD's MQTT subscription support includes MQTT 5.0, which requires Mosquitto 2.0 or later. On Ubuntu 22.04 the default `mosquitto` package is already 2.x, so no extra step is needed.

### Postgres 17
Postgres is used as database for the Temporal Evolution of entities

#### Install Postgres 17
Expand Down
44 changes: 28 additions & 16 deletions src/lib/orionld/common/orionldServerConnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
*
* Author: Ken Zangelin
*/
#include <string.h> // strerror
#include <stdio.h> // snprintf
#include <string.h> // strerror, memset
#include <unistd.h> // close
#include <netdb.h> // struct hostent
#include <netdb.h> // getaddrinfo, freeaddrinfo, gai_strerror
#include <errno.h> // errno
#include <sys/types.h> // types
#include <sys/socket.h> // socket
Expand All @@ -46,36 +47,47 @@
//
int orionldServerConnect(const char* ip, uint16_t portNo)
{
int fd;
struct hostent* heP;
struct sockaddr_in server;
// getaddrinfo is POSIX-mandated thread-safe; the older gethostbyname
// writes into a single process-wide static hostent and crashed under
// concurrent notification delivery when two MHD threads raced on that
// shared buffer.
struct addrinfo hints;
struct addrinfo* res = NULL;
char portStr[16];

Check warning on line 56 in src/lib/orionld/common/orionldServerConnect.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "std::string" instead of a C-style char array.

See more on https://sonarcloud.io/project/issues?id=FIWARE_context.Orion-LD&issues=AZ2TBKOphsFAWnegnGnA&open=AZ2TBKOphsFAWnegnGnA&pullRequest=1937
int fd;

KT_T(KtNotificationMsg, "Connecting to IP: '%s'", ip);
heP = gethostbyname(ip);
if (heP == NULL)

memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_NUMERICSERV; // port is a numeric string — skip servent lookup

snprintf(portStr, sizeof(portStr), "%u", portNo);

Check warning on line 66 in src/lib/orionld/common/orionldServerConnect.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "std::format" or "std::format_to_n" instead of "snprintf".

See more on https://sonarcloud.io/project/issues?id=FIWARE_context.Orion-LD&issues=AZ2TBKOphsFAWnegnGm_&open=AZ2TBKOphsFAWnegnGm_&pullRequest=1937

int rc = getaddrinfo(ip, portStr, &hints, &res);
if (rc != 0 || res == NULL)

Check failure on line 69 in src/lib/orionld/common/orionldServerConnect.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the "nullptr" literal.

See more on https://sonarcloud.io/project/issues?id=FIWARE_context.Orion-LD&issues=AZ2TBKOphsFAWnegnGnB&open=AZ2TBKOphsFAWnegnGnB&pullRequest=1937
{
KT_E("unable to find host '%s'", ip);
KT_E("unable to resolve host '%s': %s", ip, gai_strerror(rc));
return -1;
}

fd = socket(AF_INET, SOCK_STREAM, 0);
fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (fd == -1)
{
KT_E("Can't even create a socket: %s", strerror(errno));
freeaddrinfo(res);
return -1;
}

server.sin_family = AF_INET;
server.sin_port = htons(portNo);
server.sin_addr = *((struct in_addr*) heP->h_addr);
bzero(&server.sin_zero, 8);

if (connect(fd, (struct sockaddr*) &server, sizeof(struct sockaddr)) == -1)
if (connect(fd, res->ai_addr, res->ai_addrlen) == -1)
{
close(fd);
KT_E("Unable to connect to host/port: %s:%d", ip, portNo);
close(fd);
freeaddrinfo(res);
return -1;
}

freeaddrinfo(res);
return fd;
}
Loading