raphaelcohn / bish-bosh

MQTT shell script client, for bash, dash, BusyBox ash and others. Gives you MQTT on anything Unix like, from embedded routers to AIX servers with almost no dependenices.
https://github.com/raphaelcohn/bish-bosh
Other
216 stars 37 forks source link

FAIL: Sent retransmission '' (padded as ' ') already exists for '2' at path ... #10

Open arnaudlds opened 6 years ago

arnaudlds commented 6 years ago

Hi ! First of all, great work on Bish-bosh, it is everything I needed for the project I'm working on and works great. The only problem is the one I'm seeing right now: I run Bish-bosh on a raspberry pi, and as it is far from the wifi access point, it is often subject to deconnections/reconnections. In order not to miss any messages sent during the time the raspberry wasn't connected to the broker, I use persistent sessions (bishbosh_connect_cleanSession=0). It works for a bit of time, but at some point, I get the following error and bish-bosh won't reconnect:

Mar 26 09:06:57 adria bish-bosh[1118]: /opt/bish-bosh/bish-bosh: 71: [: -ge: unexpected operator Mar 26 09:06:57 adria bish-bosh[1118]: /opt/bish-bosh/bish-bosh: 71: [: -ge: unexpected operator Mar 26 09:06:57 adria bish-bosh[1118]: ln: failed to create symbolic link '/opt/bish-bosh/var/spool/bish-bosh/session/servers/192.168.10.101/ports/1883/client-ids/_adria/retransmission/ /2': File exists Mar 26 09:06:57 adria bish-bosh[1118]: bish-bosh: FAIL: Sent retransmission '' (padded as ' ') already exists for '2' at path '/opt/bish-bosh/var/spool/bish-bosh/session/servers/192.168.10.101/ports/1883/client-ids/_adria/retransmission/ '.

The only thing to get it working again is change my scriplet, delete the line bishbosh_connect_cleanSession=0, connect again without the persistent session, add the line again and reconnect.

I'm running bish-bosh as a service in order to restart it everytime it loses the connection to the wifi, I don't know if it is a great idea but that's all I could find in order to run the raspberry headless without hogging a terminal. Here is the configuration:

[Unit] Description=MQTT Shell Client [Service] WorkingDirectory=/opt/bish-bosh/ ExecStart=/opt/bish-bosh/bish-bosh -- /opt/bish-bosh/script Restart=always TimeoutStartSec=120 StartLimitIntervalSec=5 StartLimitBurst=2 StandardOutput=syslog StandardError=syslog User=root Group=root [Install] WantedBy=network-onlline.target Alias=bish-bosh.service

Here is my bish-bosh scriplet:

!/usr/bin/env bish-bosh

bishbosh_connect_cleanSession=0 bishbosh_server="192.168.10.101" bishbosh_port=1883 bishbosh_clientId="adria" bishbosh_connect_username= bishbosh_connect_password= bishbosh_connect_keepAlive=5 bishbosh_connect_willTopic="test/new/" bishbosh_connect_willMessage="ADRIA : Goodbye Cruel World :(" bishbosh_connect_willQoS=1 bishbosh_connect_willRetain=0 bishbosh_connection_handler_CONNACK() { bishbosh_subscribe 'test/new/adria' 1 bishbosh_subscribe 'test/new/' 1 bishbosh_subscribe 'test' 1 bishbosh_publishText 1 'test/new/' no "ADRIA Connected $(date +%d-%m-%Y" "%H:%M:%S)" } bishbosh_connection_handler_PUBLISH() { date="$(/bin/date +%d-%m-%Y" "%H:%M:%S) :" message="$(/bin/cat ${messageFilePath})" echo "${date} Message ${message} Received on Topic ${topicName}" >> /var/log/bish-bosh.log }

Any idea what might be the problem and how it could be avoided? Thx in advance!

PS: Another very minor thing: the topic name isn't displayed in my log file when using echo ${topicName}.