Arduino MQTT Hang

Hi

I'm using an Arduino Mega, with an Arduino Ethernet shield, to recieve messages via a self hosted MQTT broker(http://mqtt.org).

Upon receiving the string "print-node-1", the Arduino then scrapes a webpage and prints some data through an AdaFruit Thermal printer.

After this, the Arduino reconnects to the MQTT broker.

The problem I'm facing is - the Arduino sometimes hangs and doesn't connect after a while. It usually displays a strange character on the Serial Monitor, usually 'Ð'.

I was wondering what this might be, and what I might do to isolate the bug, or rectify it?

Code is below in a paste bin.

http://pastebin.com/c62C94Dv

Many thanks

Code is below in a paste bin.

I don't (can't) do rubbish bin. There is a perfectly good mechanism for posting code here, using the Additional Options link below the text entry window, if necessary.

caidavies: Hi

I'm using an Arduino Mega, with an Arduino Ethernet shield, to recieve messages via a self hosted MQTT broker(http://mqtt.org). ...

The problem I'm facing is - the Arduino sometimes hangs and doesn't connect after a while. It usually displays a strange character on the Serial Monitor, usually 'Ð'.

I was wondering what this might be, and what I might do to isolate the bug, or rectify it?

Many thanks

Hey, Might the problem be your "client.connect" always returning false? I'm doing a similar thing, using the pubsubclient.h library. I haven't been able to figure out why "client.connect" returns false for very long periods of time.