MQTT Stopped working randomly? Help please

HI all

I have a arduino running as a motion sensor for some lights outdoors and to trigger my security cameras
Last night I tested it and it worked perfectly, but on my way to work in the morning I noted the lights didnt turn on when i went past my sensor

I had a look at the logs and around 3am the arduino supposedly lost connection with the mqtt server and never re-connected

I tested my code again, and loaded just the basic mqtt example code, but neither of them would connect
I get an IP address, and I can ping that IP from my computer, so I know the ethernet is working somewhat properly

but all I get is the RC:-2 error when It tried to connect to the mqtt server

my server is ok as I have other devices connected to it and sending / receiving messages

Does anyone have any ideas?

Code past here: (stripped out the extra code minus the MQTT stuff, as i did that while testing and it still didnt work)

Ignore me. figured it out

When i originally wrote my code, my reconnect function was wrong, so when it lost connection it didnt reconnect
which is what broke it last night

and when I re-did my code to have the reconnect, i put the mqtt connect function before the setup commands, so it was trying to connect to a server it had no idea about

Noting for future reference if anyone has this problem in future