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

Error while sending message with Raspberry Pi #4

Open Haves1001 opened 9 years ago

Haves1001 commented 9 years ago

I tried to execute the following test code on my raspberry pi:

bishbosh_clientId=12

bishbosh_connection_handler_CONNACK()
{
    # Set up some subscriptions... another implementation could read from a standard file
    bishbosh_subscribe \
        '/topic/qos/0' 0 \
        '/topic/qos/1' 1 \
        '/topic/qos/3' 1

    bishbosh_unsubscribe \
        '/topic/not/wanted' \
        '/and/also/topic/not/wanted'

    # Publish a QoS 0 message
    # On topic a/b
    # Unretained
    # With value 'X'
    bishbosh_publishText 0 'a/b' no 'My message'
    #bishbosh_publishFile 1 'a/b' no '/tmp/test.dat'
}

bishbosh_connection_handler_PUBLISH()
{
    echo "Message received: retain=$retain, QoS=$QoS, dup=$dup, topicLength=$topicLength, topicName=$topicName, messageLength=$messageLength, messageFilePath=$messageFilePath"
}

bishbosh_connection_handler_noControlPacketsRead()
{
    # This event happens every few milliseconds - use this to publish some messages, change subscriptions or reload our configuration. Perhaps we could monitor a folder path?
    # bishbosh_publishText 0 'nowt' no 'hello world'
    echo 'No Control Packages Read' 1>&2
}

And get the following error. This is caused by bishbosh_publishText. Is there a mistake I don't see?

pi@raspberrypi ~ $  sudo ./mqtt/bish-bosh/bish-bosh --verbose 10 -- /tmp/bish-bosh.example
bish-bosh: INFO: Using backend 'ncat' (on path '/usr/bin/ncat') with port '1883'
bish-bosh: DEBUG: Passing options to backend 'ncat' using '/usr/bin/ncat' as '-w 30 -v -v test.mosquitto.org 1883' (please note spaces ARE handled correctly)
bish-bosh: DEBUG: bishbosh_connection_clientPid is 20555
bish-bosh: INFO: Using stdbuf (stdbuf) with od (od)
bish-bosh: DEBUG: bishbosh_connection_hexConversionPid is 20566
Ncat: bish-bosh: INFO: Writing CONNECT
Version 6.00 ( http://nmap.org/ncat )
bish-bosh: DEBUG: bishbosh_connection_processLoopPid is 20571
bish-bosh: DEBUG: bishbosh_connection_processingLoopReadInterrupterPid is 20582
bish-bosh: DEBUG: Our Pid is 20275
bish-bosh: NOTICE: Terminate bish-bosh with  kill 20275
Ncat: Connected to 85.119.83.194:1883.
./mqtt/bish-bosh/bish-bosh: 1: eval: message: parameter not set
bish-bosh: FAIL: processLoop failed
raphaelcohn commented 9 years ago

Thanks for taking time the time to report a problem. It looks like an undeclared variable. These can be quite hard to debug in shell script. Could you modify your script to have a set -x (eg as the second line of bish-bosh) and publish the resultant stderr output here or as a gist, please?

Haves1001 commented 9 years ago

Hopefully I got it right. Does this gist help you?

https://gist.github.com/henningvs/e8ee42075b929dcd2ec5

raphaelcohn commented 9 years ago

Ta. Let me start taking a look. I'm mostly tidied up until Monday, so I may not get back to you until then.

Haves1001 commented 9 years ago

Ok thanks anyway for your effort and your time. That is some great piece of software you developed!

raphaelcohn commented 9 years ago

I've made a bug fix and a new release - https://github.com/raphaelcohn/bish-bosh/releases/tag/release_2015.0629.0920-4 . Having problems with network connectivity at the moment, so there may still be issues. Could you test and let me know?

Haves1001 commented 9 years ago

This seems to be working. At least it isn't throwing an error anymore.

Unfortunately I don't receive the messages I sent. As far as I read the logs properly.

sudo ./mqtt/bish-bosh/bish-bosh --verbose 2 -- /tmp/bish-bosh2.example
bish-bosh: INFO: Using backend 'ncat' (on path '/usr/bin/ncat') with port '1883'
bish-bosh: INFO: Using stdbuf (stdbuf) with od (od)
bish-bosh: INFO: Writing CONNECT
Ncat: Version 6.00 ( http://nmap.org/ncat )
bish-bosh: NOTICE: Terminate bish-bosh with  kill 21678
Ncat: Connected to 85.119.83.194:1883.
bish-bosh: INFO: Received valid CONNACK
raphaelcohn commented 9 years ago

Hmmm... On 29 Jun 2015 13:51, "Henning von See" notifications@github.com wrote:

This seems to be working. At least it isn't throwing an error anymore.

Unfortunately I don't receive the messages I sent. As far as I read the logs properly.

sudo ./mqtt/bish-bosh/bish-bosh --verbose 2 -- /tmp/bish-bosh2.example bish-bosh: INFO: Using backend 'ncat' (on path '/usr/bin/ncat') with port '1883' bish-bosh: INFO: Using stdbuf (stdbuf) with od (od) bish-bosh: INFO: Writing CONNECT Ncat: Version 6.00 ( http://nmap.org/ncat ) bish-bosh: NOTICE: Terminate bish-bosh with kill 21678 Ncat: Connected to 85.119.83.194:1883. bish-bosh: INFO: Received valid CONNACK

— Reply to this email directly or view it on GitHub https://github.com/raphaelcohn/bish-bosh/issues/4#issuecomment-116647029 .

Haves1001 commented 9 years ago

But it seems like they are sent.

bish-bosh: INFO: processLoop terminating because of signal
bish-bosh: INFO: Writing DISCONNECT
Ncat: 2577 bytes sent, 15 bytes received in 20.69 seconds.
stormmq commented 9 years ago

Could you send me another set -x gist? On 29 Jun 2015 13:53, "Henning von See" notifications@github.com wrote:

But it seems like they are sent.

bish-bosh: INFO: processLoop terminating because of signal bish-bosh: INFO: Writing DISCONNECT Ncat: 2577 bytes sent, 15 bytes received in 20.69 seconds.

— Reply to this email directly or view it on GitHub https://github.com/raphaelcohn/bish-bosh/issues/4#issuecomment-116647756 .

Haves1001 commented 9 years ago

Sure. I hope this helps:

https://gist.github.com/henningvs/07e3f3c4a867be24eb4b

raphaelcohn commented 9 years ago

Ok ill take a look. On 29 Jun 2015 13:59, "Henning von See" notifications@github.com wrote:

Sure. I hope this helps:

https://gist.github.com/henningvs/07e3f3c4a867be24eb4b

— Reply to this email directly or view it on GitHub https://github.com/raphaelcohn/bish-bosh/issues/4#issuecomment-116650183 .

Haves1001 commented 9 years ago

Thanks, let me know if you need more information.

raphaelcohn commented 9 years ago

Sorry I haven't been able to look at this yet.

CODeRUS commented 7 years ago

I also have problem with raspbian: https://gist.github.com/CODeRUS/5c768e9eca696f6cc59bf2b7da7f92ad