Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

No Gateway found when enabling Authentication #242

Open
nikhil30081995 opened this issue Aug 9, 2021 · 18 comments
Open

No Gateway found when enabling Authentication #242

nikhil30081995 opened this issue Aug 9, 2021 · 18 comments
Labels

Comments

@nikhil30081995
Copy link

Hello,
As i have mentioned before i want to connect my MQTT-SN network to AWS cloud. So for that purpose i have to enable the Authentication to YES. When i enable the authentication in Paho Gateway configuration file, my MQTTSN client devices are unable to find gateway.

What could be the issue here ?
First of all in client.conf file that i have passed there is no much clarity regarding which address should i pass. Currently all my MQTT-SN clients are connecting to local broker with same IP address and different client names. So should i use that IP address ? And which port should i use. In my open thread based application the default PORT that's used is 47193.

Please help me to solve this issue.

Below i have attached my configuration file for clients, where i don't know which IP address and Port to use. Here the clients.conf file already had Gateway Tester and Client Pub Client1,2,3 configuration by default I had only added the last entry.

Here is clients.conf file :
GatewayTester, 172.16.1.11:20020
ClientPUB,172.16.1.11:2010
Client01,172.16.1.11:12001
Client02,172.16.1.11:12002
Client03,172.16.1.11:13003
P-l496G-CELL01,192.168.1.102:1883

@ty4tw
Copy link
Contributor

ty4tw commented Aug 11, 2021

Hi,

If Authentication of gateway.conf is YES, GW checks whether ClientId, IP address and PortNo of the sent CONNECT message are registered in the clientList. If they do not match, CONNECT is ignored.
therefore,

P-l496G-CELL01,192.168.1.102:1883

must be changed to

P-l496G-CELL01,192.168.1.102:47193,secureConnection

PortNo 1883 is for multicast.  
If secureConnection is specified, the GW will connect the client to the broker with TLS.
GW uses the following keys for TLS connections.

RootCAfile=/etc/ssl/certs/ca-certificates.crt
RootCApath=/etc/ssl/certs/
CertsKey=/path/to/certKey.pem
PrivateKey=/path/to/privateKey.pem

@ty4tw ty4tw added the question label Aug 11, 2021
@nikhil30081995
Copy link
Author

nikhil30081995 commented Aug 21, 2021

Hello,
I would like to know which IP address i should use in the clients.conf file ? Because the IP address of my connected device might get change when i connect to different WiFI connection.

I have tried with your advice but still MQTT-SN clients are unable to search gateway. When i disable the Authentication, then my MQTT-SN clients are able to find gateway.

Gateway Config File: (Ports are configured by Nordic to run with Nordic OpenThread Examples)
BrokerName=xxxxxxxxxxxxxxxats.iot.ap-south-1.amazonaws.com
BrokerPortNo=1883
BrokerSecurePortNo=8883

ClientAuthentication=YES
AggregatingGateway=NO
QoS-1=NO
Forwarder=NO

ClientsList=/etc/clients.conf

PredefinedTopic=NO
#PredefinedTopicList=/etc/topics.conf

RootCAfile=/etc/mosquitto/certs/rootCA.pem
RootCApath=/etc/mosquitto/certs/
CertsFile=/etc/mosquitto/certs/cert.crt
PrivateKey=/etc/mosquitto/certs/private.key

GatewayID=1
GatewayName=PahoGateway-01
KeepAlive=900

GatewayPortNo=10000
MulticastIP=225.1.1.1
MulticastPortNo=1883
MulticastTTL=1

GatewayUDP6Port = 47193
GatewayUDP6Broadcast = ff33:40:fdde:ad00:beef:0:0:1
GatewayUDP6If = wpan0
GatewayUDP6Hops=5

And here is my Clients.config file :

snode,192.168.1.102:47193,secureConnection
snode1,127.0.0.1:47193,secureConnection
snode2,192.168.0.6:47193,secureConnection

@ty4tw
Copy link
Contributor

ty4tw commented Aug 21, 2021

Hi,

Could you attach a gateway log?
There might be an error message like “client was rejected”.

@nikhil30081995
Copy link
Author

nikhil30081995 commented Oct 4, 2021

Actually i was not able to watch logs due to some reason. So I retried installing MQTT-SN gateway for Nordics Open Thread example as the MQTT-SN gateway installed in Nordic Border Router image for Thread is little old version ad86a27.

I would like to install the latest MQTT-SN gateway on RPi. So can you suggest me which is the latest and the stable version ? I have build the latest master repo and build the gateway.

Have followed the steps mentioned here as answer to replace the previous mqtt-sn gateway with new build. But now when i restart the mqtt-sn gateway i get the following error:
image
Gateway Error

@osaether
Copy link

osaether commented Oct 4, 2021

@nikhil30081995 Did you specify udp6 when building? Like this:
./build.sh udp6

I have created a docker image with MQTT-SN with OT BR. I use a slightly older version than the master of MQTT-SN (I did not get the latest one to work due to different syntax in the gateway.conf file). Project here:
https://github.com/osaether/otbr-mqtt-sn

@nikhil30081995
Copy link
Author

nikhil30081995 commented Oct 4, 2021

Hello, yes i specified udp6 while building. Actually i am experimenting with Nordic Image for Border Router as Jonathan Hui from open thread itself suggested me to use nordic image for border router as i am trying out nordic thread examples.

I have used the latest master version of MQTT-SN gateway. In RPi as Marry stated in post on dev zone:

Stop the currently running gateway:
$ sudo systemctl stop paho-mqttsn-gateway.service

Edit the service file:
$ sudo nano /etc/systemd/system/paho-mqttsn-gateway.service

Change the ExecStart line to explicitly specify the configuration file:
ExecStart=/usr/sbin/MQTT-SNGateway -f /etc/paho-mqtt-sn-gateway.conf

And restarted the mqttsn gateway.

The configuration file which i passed is the default configuration file provided in Nordic Image.

@osaether
Copy link

osaether commented Oct 4, 2021

@nikhil30081995 I believe some of the parameters in gateway.conf have changed in the lastest master. Example:
GatewayUDP6If is now called MulticastIPv6If
GatewayUDP6Hops is now called MulticastHops
and several others.

Am I right @ty4tw ?

@nikhil30081995
Copy link
Author

I use a slightly older version than the master of MQTT-SN

Which version did you tried out ? I would also like to check that out on the Nordic Image.

@osaether
Copy link

osaether commented Oct 4, 2021

I am using commit f2dcda3

@nikhil30081995
Copy link
Author

Okay i will try that out.
From the image i have attached can you tell me what could be the issue ? And the docker image which you have provided is it exactly similar to the Nordic border router image. Like it have all other setup too ?

@osaether
Copy link

osaether commented Oct 4, 2021

@nikhil30081995 I don't think my Docker image is exactly like the Nordic BR image but I have successfully used this Docker with the Nordic sleepy end device samples.

@nikhil30081995
Copy link
Author

nikhil30081995 commented Oct 5, 2021

@osaether In the commit which you have used the MAX_CLIENTS is still set to 100, while most of the developer suggestion was to increase the value of max clients. I would like to know what could be the valid value of MAX_CLIENTS ?

I see that the following parameters are added in the configuration file, which were not present before:
MaxNumberOfClients=30; And under UDP6 GatewayUDP6Bind=FFFF:FFFE::1 , GatewayUDP6Hops=1.
What's the limit of MaxNumberOfClients ? And is GatewayUDP6Bind necessary for nordic open thread examples ?

@nikhil30081995
Copy link
Author

@osaether I have successfully built the version of MQTT-SN Gateway that you have mentioned and used in docker image.
I have configured MQTT-SN gateway to connect to local mosquito broker. When i run the Nordic examples, everything runs fine. But to test worst case scenario, when i restart the local mosquitto broker, i can see the following LOG message on my MQTTSN Log teminal :
MQTTSNLogError

In Segger Studio debugging the nRF MQTTSN Publish example shows error on Assert line 364 in mqttsn_client.c file:

` case MQTTSN_CLIENT_CONNECTED:
{
switch (fsm_event)
{
case SENT_SLEEP_REQUEST:
p_client->client_state = MQTTSN_CLIENT_WAITING_FOR_SLEEP;
break;

            case SENT_DISCONNECT_REQUEST:
                p_client->client_state = MQTTSN_CLIENT_WAITING_FOR_DISCONNECT;
                break;

            case TIMEOUT_PINGREQ:
                p_client->client_state = MQTTSN_CLIENT_DISCONNECTED;
                break;

            case SENT_PINGREQ:
                break;

            case RECEIVED_PINGRESP:
                break;

            default:
                ASSERT(false);
                break;
        }
        break;
    }

`

Have you tested this ? And what could be the possible reason ?

@osaether
Copy link

osaether commented Oct 6, 2021

@nikhil30081995 I don't think the Nordic samples are designed to handle disconnects. I have made my own sleepy publisher that reconnects. You can take a look here:
https://github.com/osaether/nrf_cell_mon

@nikhil30081995
Copy link
Author

@nikhil30081995 I don't think the Nordic samples are designed to handle disconnects. I have made my own sleepy publisher that reconnects. You can take a look here: https://github.com/osaether/nrf_cell_mon

Hello, your project was good reference point. Instead of using app event scheduler i have made used of timers to for gateway search, connection establishment and publishing purpose.

Can you suggest me which method should i use ? app_timer or event_scheduler ? In your application, you have assumed that the mqttsn connect packet will get transmitted always. What happens if it doesn't ?

@osaether
Copy link

osaether commented Oct 6, 2021

@nikhil30081995
I think using a timer is fine.
For my setup it looks like this packet is sent always. I tried to power off the device and on again and it connected after a couple of seconds.

@nikhil30081995
Copy link
Author

@osaether Okay. Thanks.
Your project was of great help.
Now i can move to main topic "No Gateway found when enabling Authentication"

@nikhil30081995
Copy link
Author

Hello @osaether @ty4tw

I am using commit f2dcda3 for MQTT_SN gateway as suggested by the @osaether for Nordic examples. My setup was working fine for week but suddenly now my devices are unable to connect to MQTT-SN gateway. I am able to search gateway and get gateway information but when i send Connection request, it show the following error in Rpi terminal.

" Cant connect to broker. error=113 No route to host "

Here is the image from RPI:

MQTTSNGateway

So can anyone please help me out what could be the issue here ?

My end device work flow is :
search gw -> connect ->gw -> topic register -> publish data -> dis-connect client ->delay 30sec -> connect ->gw -> topic register -> publish data -> dis-connect client -> connect ->gw -> topic register -> publish data -> dis-connect client

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants