Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [paho-dev] MQTTSNGateway and AWS IoT

Hello Tomoaki,

I use njh.mqtt-sn-tools for command line publish/subscribe.
gateway.conf - configuration file
gateway.log - log file

I'm starting gateway, and then trying to subscribe to the topic:

njh.mqtt-sn-tools$ ./mqtt-sn-sub -h 127.0.0.1 -p 10000 -t topic1
2017-07-27 15:28:26 ERROR Keep alive error: timed out while waiting for
a PUBLISH from gateway.
njh.mqtt-sn-tools$

When I'm adding a simple parameters check to the Network::recv()
function, the subscribing starts working well. Otherwise, client
disconnected after first PINGREQ.

SSL_ERROR_ZERO_RETURN error code after the publish operation is not a
problem. It appears every time when "mqtt-sn-pub" utility disconnecting
from Gateway.


With best regards, Sergey.


27.07.2017 12:27, Tomoaki Yamaguchi wrote:
> Hi,
> 
> I could not recreate your bug.
> I tried Raspbery Pi Model A and corei7 ubuntu.
> see attached log of the gateway.
> 
> I tested it by the GatewayTester in the repo.
> 
> 
> 
> Tomy Technology
> Tomoaki  YAMAGUCHI
> 
> 2017-07-22 13:11 GMT+09:00 Tomoaki Yamaguchi <tomoaki@xxxxxxxxxxxxx
> <mailto:tomoaki@xxxxxxxxxxxxx>>:
> 
>     Hi,
> 
>     Thank you for your information.
>     I'm working on it.
> 
>     Tomy Technology
>     Tomoaki  YAMAGUCHI
> 
>     2017-07-20 22:46 GMT+09:00 Sergey Semernin
>     <sergey.semernin@xxxxxxxxx <mailto:sergey.semernin@xxxxxxxxx>>:
> 
>         Hello Tomoaki,
> 
>         Looks like the problem in the function
>             int Network::recv(uint8_t* buf, uint16_t len)
>         called with len == 0 from function
>             int MQTTGWPacket::recv(Network* network)
>         line
>             int remlen = network->recv(_data, _remainingLength);
> 
>         Then, the SSL_read() call fails with SSL_ERROR_SYSCALL, and next
>         SSL_read() call always fails with SSL_ERROR_ZERO_RETURN.
> 
>         I've add simple check to the begin of Network::recv() function:
>             if (!buf)
>                 return -1;
>             if (!len)
>                 return 0;
>         And subscribing to a topic messages starts to work normally.
> 
>         However, after each publish operation (message successfully sent
>         to the
>         AWS message broker) the SSL_read() call fails with
>         SSL_ERROR_ZERO_RETURN. I don't understand why yet.
> 
>         Therefore looks like there are problems in the SSL code of the
>         MQTTSNGateway. I checked my AWS IoT configuration using
>         RSMB+Mosquitto,
>         and all works well (using same SSL certificates, of course).
> 
> 
>         With best regards, Sergey.
> 
> 
>         19.07.2017 14:24, Tomoaki Yamaguchi wrote:
>         > Hi Sergey,
>         >
>         > I checked the gateway was working with AWS IoT before.
>         > I will check it again.
>         >
>         > could you try TLS 1.2 ?
>         >
>         >
>         >
>         > Tomy Technology
>         > Tomoaki  YAMAGUCHI
>         >
>         > 2017-07-19 20:17 GMT+09:00 Sergey Semernin <sergey.semernin@xxxxxxxxx <mailto:sergey.semernin@xxxxxxxxx>
>         > <mailto:sergey.semernin@xxxxxxxxx
>         <mailto:sergey.semernin@xxxxxxxxx>>>:
>         >
>         >     Hello Tomoaki,
>         >
>         >     Thank you for the answer, and sorry for my english.
>         >
>         >     Yes, of course. I also tried to change client identification string, and
>         >     then I got error message that client is rejected by the gateway. So,
>         >     client authentication is working well.
>         >
>         >     Build system: Debian GNU/Linux 9.0, SSL version 1.1.0f.
>         >
>         >     I see successful SSL connection handshake between Gateway and AWS
>         >     server. But then, the Gateway somehow closing this connection.
>         >     I tried to deactivate AWS keypair, and then I got "connection error to
>         >     the broker" on gateway, as expected. So, keypairs is valid too. Some
>         >     problem in send()/recv() cycle, I suppose.
>         >
>         >
>         >     With best regards, Sergey.
>         >
>         >
>         >     19.07.2017 14:05, Tomoaki Yamaguchi wrote:
>         >     > Hi,
>         >     >
>         >     > Did you register your ClientID and SensorNet Address address to
>         >     > clients.conf ?
>         >     >
>         >     > In order to authenticate the client, the gateway confirms that the ID
>         >     > and SensorNet Address are registered in clients.conf in case of TLS
>         >     > connection.
>         >     >
>         >     >
>         >     > Tomy Technology
>         >     > Tomoaki  YAMAGUCHI
>         >     >
>         >     > 2017-07-19 18:21 GMT+09:00 Sergey Semernin <sergey.semernin@xxxxxxxxx <mailto:sergey.semernin@xxxxxxxxx>
>         <mailto:sergey.semernin@xxxxxxxxx
>         <mailto:sergey.semernin@xxxxxxxxx>>
>         >     > <mailto:sergey.semernin@xxxxxxxxx
>         <mailto:sergey.semernin@xxxxxxxxx>
>         >     <mailto:sergey.semernin@xxxxxxxxx <mailto:sergey.semernin@xxxxxxxxx>>>>:
>         >     >
>         >     >     Hello All!
>         >     >
>         >     >     I'm new to transparent MQTT-SN gateway that published in Paho project.
>         >     >     I'm trying to test this gateway with Amazon MQTT message broker. I set
>         >     >     up SSL/TLS certificates, test connection to the MQTT, and it works.
>         >     >
>         >     >     Then, I setup gateway:
>         >     >
>         >     >     BrokerName=....iot.eu-central-1.amazonaws.com
>         <http://iot.eu-central-1.amazonaws.com>
>         <http://iot.eu-central-1.amazonaws.com
>         <http://iot.eu-central-1.amazonaws.com>>
>         >     >     <http://iot.eu-central-1.amazonaws.com
>         <http://iot.eu-central-1.amazonaws.com>
>         >     <http://iot.eu-central-1.amazonaws.com
>         <http://iot.eu-central-1.amazonaws.com>>>
>         >     >     BrokerPortNo=1883
>         >     >     BrokerSecurePortNo=8883
>         >     >     ClientAuthentication=YES
>         >     >     ClientsList=clients.conf
>         >     >
>         >     >     RootCAfile=root-CA.crt
>         >     >     CertKey=my-certificate.pem.crt
>         >     >     PrivateKey=my-private.pem.key
>         >     >
>         >     >     GatewayID=1
>         >     >     GatewayName=PahoGateway-01
>         >     >     KeepAlive=900
>         >     >
>         >     >     GatewayPortNo=10000
>         >     >     MulticastIP=225.1.1.1
>         >     >     MulticastPortNo=1883
>         >     >
>         >     >     And I'm trying to publish or subscribe with
>         mqtt-sn-tools.
>         >     >     Each time I got this error:
>         >     >
>         >     >     20170719 120527.230   CONNECT           <--- 
>         mqtt-sn-tools-7142
>         >     >              04 04 01 00 0A 6D 71 74 74 2D 73 6E 2D 74
>         6F 6F 6C 73
>         >     2D 37 31
>         >     >     34 32
>         >     >     20170719 120527.910   CONNECT           ---> 
>         mqtt-sn-tools-7142
>         >     >              10 1E 00 04 4D 51 54 54 04 02 00 0A 00 12
>         6D 71 74 74
>         >     2D 73 6E
>         >     >     2D 74 6F 6F 6C 73 2D 37 31 34 32
>         >     >     Error: BrokerRecvTask can't receive a packet from
>         the broker
>         >     errno=0
>         >     >     mqtt-sn-tools-7142
>         >     >
>         >     >     I checked traffic with tcpdump and saw that SSL/TLS
>         connection
>         >     with AWS
>         >     >     cloud is present. But nothing more.
>         >     >
>         >     >     What I missed? Or this gateway just not working/not
>         tested
>         >     with AWS MQTT
>         >     >     broker?
>         >     >
>         >     >
>         >     >     With best regards, Sergey.
>         >     >     _______________________________________________
>         >     >     paho-dev mailing list
>         >     >     paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>
>         <mailto:paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>>
>         >     <mailto:paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>
>         <mailto:paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>>>
>         >     >     To change your delivery options, retrieve your
>         password, or
>         >     >     unsubscribe from this list, visit
>         >     >     https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>
>         >     <https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>>
>         >     >     <https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>
>         >     <https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>>>
>         >     >
>         >     >
>         >     >
>         >     >
>         >     > _______________________________________________
>         >     > paho-dev mailing list
>         >     > paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>
>         <mailto:paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>>
>         >     > To change your delivery options, retrieve your password, or
>         >     unsubscribe from this list, visit
>         >     > https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>
>         >     <https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>>
>         >     >
>         >     _______________________________________________
>         >     paho-dev mailing list
>         >     paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>
>         <mailto:paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>>
>         >     To change your delivery options, retrieve your password, or
>         >     unsubscribe from this list, visit
>         >     https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>
>         >     <https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>>
>         >
>         >
>         >
>         >
>         > _______________________________________________
>         > paho-dev mailing list
>         > paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>
>         > To change your delivery options, retrieve your password, or
>         unsubscribe from this list, visit
>         > https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>
>         >
>         _______________________________________________
>         paho-dev mailing list
>         paho-dev@xxxxxxxxxxx <mailto:paho-dev@xxxxxxxxxxx>
>         To change your delivery options, retrieve your password, or
>         unsubscribe from this list, visit
>         https://dev.eclipse.org/mailman/listinfo/paho-dev
>         <https://dev.eclipse.org/mailman/listinfo/paho-dev>
> 
> 
> 
> 
> 
> _______________________________________________
> paho-dev mailing list
> paho-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/paho-dev
> 
BrokerName=NNNNNNNNNNNNNN.iot.eu-central-1.amazonaws.com
BrokerPortNo=1883
BrokerSecurePortNo=8883

ClientAuthentication=YES
ClientsList=clients.conf

RootCAfile=root-CA.crt
CertKey=NNNNNNNNNN-certificate.pem.crt
PrivateKey=NNNNNNNNNN-private.pem.key

GatewayID=1
GatewayName=PahoGateway-01
KeepAlive=900

# UDP
GatewayPortNo=10000
MulticastIP=225.1.1.1
MulticastPortNo=1883

# LOG
ShearedMemory=NO
$ ./MqttSnGateway -f gateway.conf 

 ***************************************************************************
 * MQTT-SN Transparent Gateway
 * Part of Project Paho in Eclipse
 * (http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt-sn.embedded-c.git/)
 *
 * Author : Tomoaki YAMAGUCHI
 * Version: 1.0.0
 ***************************************************************************

20170727 152752.221 PahoGateway-01 has been started.

 ConfigFile: ./gateway.conf
 SensorN/W:  UDP Multicast 225.1.1.1:1883 Gateway Port 10000
 Broker:     NNNNNNNNNNNNNN.iot.eu-central-1.amazonaws.com : 1883, 8883
 RootCApath: (null)
 RootCAfile: root-CA.crt
 CertKey:    NNNNNNNNNN-certificate.pem.crt
 PrivateKey: NNNNNNNNNN-private.pem.key

20170727 152805.497   CONNECT           <---  mqtt-sn-tools-16751                 04 04 01 00 0A 6D 71 74 74 2D 73 6E 2D 74 6F 6F 6C 73 2D 31 36 37 35 31
20170727 152805.737   CONNECT           --->  mqtt-sn-tools-16751                 10 1F 00 04 4D 51 54 54 04 02 00 0A 00 13 6D 71 74 74 2D 73 6E 2D 74 6F 6F 6C 73 2D 31 36 37 35 31
20170727 152806.224   CONNACK           <---  mqtt-sn-tools-16751                 20 02 00 00
20170727 152806.224   CONNACK           --->  mqtt-sn-tools-16751                 05 00

20170727 152806.224   SUBSCRIBE   0001  <---  mqtt-sn-tools-16751                 12 00 00 01 74 6F 70 69 63 31
20170727 152806.224   SUBSCRIBE   0001  --->  mqtt-sn-tools-16751                 82 0B 00 01 00 06 74 6F 70 69 63 31 00
20170727 152806.286   SUBACK      0001  <---  mqtt-sn-tools-16751                 90 03 00 01 00
20170727 152806.286   SUBACK      0001  --->  mqtt-sn-tools-16751                 13 00 00 01 00 01 00

20170727 152816.297   PINGREQ           <---  Client                              16
20170727 152816.297   PINGREQ           --->  mqtt-sn-tools-16751                 C0 00
Error: BrokerRecvTask can't receive a packet from the broker errno=0 mqtt-sn-tools-16751
^C20170727 152843.870 BrokerSendTask   stopped.
20170727 152843.870 ClientSendTask   stopped.
20170727 152843.870 PacketHandleTask stopped.
20170727 152844.326 ClientRecvTask   stopped.
20170727 152844.342 BrokerRecvTask   stopped.

20170727 152844.870 MQTT-SN Gateway  stoped

Back to the top