ESP8266 MQTT: An error occured while uploading the sketch

Hi,

I’m currently trying to program my ESP8266 (NodeMCU8266v3) as a mosquitto client, For some unknown reason i can’t succeed in uploading my sketch to the MCU.

Whenever i try it’s all looking fine until the last 1 percent or so, Whenever it reaches this it truncates the following error: An error occurred while uploading the sketch.
I’ve verified the settings in the ide and these match the boards requirements 9600 Baud and the selected board is NodeMCU 1.0 (ESP-12E)

Sketch Source: esp8266-whr930-mqtt/esp8266-whr930-mqtt.ino at master · LukasdeBoer/esp8266-whr930-mqtt · GitHub

This is the debug output of my sketch:

Sketch uses 313668 bytes (30%) of program storage space. Maximum is 1044464 bytes.
Global variables use 30024 bytes (36%) of dynamic memory, leaving 51896 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.6
2.6
esptool.py v2.6
Serial port COM4
Connecting…
Chip is ESP8266EX
Features: WiFi
MAC: dc:4f:22:5e:a6:5e
Uploading stub…
Running stub…
Traceback (most recent call last):
File “C:\Users\Jeff\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.5.2/tools/upload.py”, line 25, in
esptool.main(fakeargs)
File “C:/Users/Jeff/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py”, line 2670, in main
esp = esp.run_stub()
File “C:/Users/Jeff/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py”, line 597, in run_stub
p = self.read()
File “C:/Users/Jeff/Documents/ArduinoData/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py”, line 277, in read
return next(self._slip_reader)
StopIteration
An error occurred while uploading the sketch

Anyone knows how i can resolve this?

Are you sure the NodeMCU is connected to com4? Is there nothing else using Com4 (like terminal program)?

Have you uploaded the Firmware for the v3 ?

The firmware was already uploaded to the MCU, Checking it with the flash tools it appears something went wrong and the MAC-address was't programmed correctly.
Also some settings weren't correct in the IDE as i'm using a clone (Lolin). I've corrected the settings after doing some extensive research and succeeded into a successful upload.