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

Hi Sergey,

Thank you for your report.
I have recreated your reported bug.

Could you make a Issue that Gateway can't received PINGRESP for future reference and your contribution.


Try the bugfix follows:

MQTTGWPacket.cpp

line 203

ÂÂÂ if ( _remainingLength > 0 )ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ <===================Â Insert this line
ÂÂÂ {
ÂÂÂ ÂÂÂ /* allocate buffer */
ÂÂÂ ÂÂÂ _data = (unsigned char*)calloc(_remainingLength, 1);
ÂÂÂ ÂÂÂ if ( !_data )
ÂÂÂ ÂÂÂ {
ÂÂÂ ÂÂÂ ÂÂÂ return -3;
ÂÂÂ ÂÂÂ }

ÂÂÂ ÂÂÂ /* read Payload */
ÂÂÂ ÂÂÂ int remlen = network->recv(_data, _remainingLength);

ÂÂÂ ÂÂÂ if (remlen == -1 )
ÂÂÂ ÂÂÂ {
ÂÂÂ ÂÂÂ ÂÂÂ return -1;
ÂÂÂ ÂÂÂ }
ÂÂÂ ÂÂÂ else if ( remlen != _remainingLength )
ÂÂÂ ÂÂÂ {
ÂÂÂ ÂÂÂ ÂÂÂ return -2;
ÂÂÂ ÂÂÂ }
ÂÂÂ }ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ <=================Â Insert this line
ÂÂÂ return 1 + len + _remainingLength;
}

int MQTTGWPacket::send(Network* network)
{



Thank you for your cooperation.

regards

Tomy Technology
Tomoaki ÂYAMAGUCHI

2017-07-27 21:42 GMT+09:00 Sergey Semernin <sergey.semernin@xxxxxxxxx>:
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@gmail.com>>:
>
>Â Â Â Â Â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@gmail.com>
>Â Â Â Â Â> <mailto:sergey.semernin@gmail.com
>Â Â Â Â Â<mailto:sergey.semernin@gmail.com>>>:
>Â Â Â Â Â>
>Â Â Â Â Â>Â Â Â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 Sensorïet Address address to
>Â Â Â Â Â>Â Â Â> clients.conf ?
>Â Â Â Â Â>Â Â Â>
>Â Â Â Â Â>Â Â Â> In order to authenticate ïïï client, the gateway confirms that the ID
>Â Â Â Â Â>Â Â Â> and Sensorïet 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@gmail.com>
>Â Â Â Â Â<mailto:sergey.semernin@gmail.com
>Â Â Â Â Â<mailto:sergey.semernin@gmail.com>>
>Â Â Â Â Â>Â Â Â> <mailto:sergey.semernin@gmail.com
>Â Â Â Â Â<mailto:sergey.semernin@gmail.com>
>Â Â Â Â Â>Â Â Â<mailto:sergey.semernin@gmail.com <mailto:sergey.semernin@gmail.com>>>>:
>Â Â Â Â Â>Â Â Â>
>Â Â Â Â Â>Â Â Â>Â Â Â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
>

_______________________________________________
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