acfloria / SatComInfrastructure

BSD 3-Clause "New" or "Revised" License
16 stars 10 forks source link

udp2mqtt error #9

Open UcefMountacer opened 3 years ago

UcefMountacer commented 3 years ago

Hi,

I had this issue and would like some help

./udp2mqtt.py
WARNING    2021-11-10 16:12:52,944 __main__                       open                                 41  : Opening UDP port 20001
WARNING    2021-11-10 16:12:52,945 __main__                       open                                 41  : Opening UDP port 10001
Traceback (most recent call last):
  File "./udp2mqtt.py", line 219, in <module>
    main()
  File "./udp2mqtt.py", line 201, in main
    mi.start() # needs to be called last because the mqtt loop is started in here
  File "./udp2mqtt.py", line 154, in start
    self.__connect()
  File "./udp2mqtt.py", line 78, in __connect
    self.__client.connect(self.__broker_ip, self.__broker_port)
  File "/home/youssef/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 914, in connect
    return self.reconnect()
  File "/home/youssef/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
  File "/home/youssef/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
  File "/usr/lib/python2.7/socket.py", line 557, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -3] Temporary failure in name resolution

I replaced url by the rockblock one (url = https://core.rock7.com/rockblock/MT:80) And for hostname : I entered the name of the device on which relay.py is running

Thanks

UcefMountacer commented 3 years ago

I get this too

./udp2mqtt.py
WARNING    2021-11-10 16:33:33,282 __main__                       open                                 41  : Opening UDP port 20001
WARNING    2021-11-10 16:33:33,282 __main__                       open                                 41  : Opening UDP port 10001
Traceback (most recent call last):
  File "./udp2mqtt.py", line 219, in <module>
    main()
  File "./udp2mqtt.py", line 201, in main
    mi.start() # needs to be called last because the mqtt loop is started in here
  File "./udp2mqtt.py", line 154, in start
    self.__connect()
  File "./udp2mqtt.py", line 78, in __connect
    self.__client.connect(self.__broker_ip, self.__broker_port)
  File "/home/youssef/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 914, in connect
    return self.reconnect()
  File "/home/youssef/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
  File "/home/youssef/.local/lib/python2.7/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
  File "/usr/lib/python2.7/socket.py", line 575, in create_connection
    raise err
socket.error: [Errno 111] Connection refused

My relay.cfg:

# MQTT broker (mosquitto) connection details
# Default port is 1883
[mqtt]

port = 1883

# change stuff here:    v   v   v   v   v   v   v   v   v   v   v   v   v   
#---------------------------------------------------------------------------

# relay server address:
# for simulator
#hostname = localhost

# for real application
hostname = 192.168.1.6

# Local UDP connection details
[lte]

# UDP port on which the relay server is listening for messages
target_port = 30000

# Timeout for messages received from the plane. If no messages are received
# during this timespan the host ip and port of the plane are reset. [s]
timeout = 600

[iridium]
# Timeout for messages received from the plane. If no messages are received
# during this timespan the MQTT queue is cleared. [s]
timeout = 600

# Address of the destination Rock7 HTTP gateway:
# for simulator
#url = http://localhost:45678

# for real application
url = https://core.rock7.com/rockblock/MT:80

#---------------------------------------------------------------------------
#   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^

# Local port listening for MT messages from the Iridium gateway
local_port = 45679

and my udp2mqtt.cfg

# MQTT message broker (mosquitto) connection details
# Default port is 1883
[mqtt]

# change stuff here:    v   v   v   v   v   v   v   v   v   v   v   v   v   
#---------------------------------------------------------------------------

# relay server address:
# for simulator
#hostname = localhost

# for real application
hostname = 192.168.1.6

#---------------------------------------------------------------------------
#   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^   ^

port = 1883

# Local UDP connection details
[lte]

# UDP port on which QGC is listening for messages
listening_port = 20000

# UDP port listening for messages sent by QGC
target_port = 20001

# Local UDP connection details
[satcom]

# UDP port on which QGC is listening for messages
listening_port = 10000

# UDP port listening for messages sent by QGC
target_port = 10001

I hope I can get a bit of help from you @acfloria , I have doubts in these cfg files.

Thanks :)

acfloria commented 3 years ago

Hi,

I cannot say for sure what causes these errors but to me it looks as if the UDP ports are not open on your devices. Did you make sure the UDP ports are open on the relay server side and on the ground station? The relay script runs as expected?

seanculbertson commented 2 years ago

Hey there, I wanted to post in this thread because I ran into this same issue and spent a couple days troubleshooting. It looks like the issue is that Mosquitto was updated to v2.0.0 in December 2020, and the default security settings are more restricted than before.

https://mosquitto.org/blog/2020/12/version-2-0-0-released/

The migration guide mentions changing the configuration file slightly:

https://mosquitto.org/documentation/migrating-to-2-0/

I haven't tested the system end to end with the Iridium radio in the loop quite yet, but the only change I made was to add "listener 1883" to the config file. My Mosquitto default.conf file on the relay server looks like this:

allow_anonymous false
password_file /etc/mosquitto/passwd
listener 1883

At this stage, I'm able to send a test message on the RockBlock website, see the message come through on the relay server, and then on the GCS computer.

acfloria commented 2 years ago

Great, thanks a lot for your feedback. If you have tested the full loop you could open a PR with the changes such that you get appropriately accredited with your contributions.