Electron Handshake fail, code 17, serial monitor stops working [Solved?]

I keep getting the following Logger message, which is accompanied by my cloud connection going down and the serial monitor output stopping:

0000244141 [comm.dtls] ERROR: handshake failed -1

0000244141 [comm.protocol.handshake] ERROR: handshake failed with code 17

0000244143 [system] WARN: Cloud handshake failed, code=17

What is code 17?

Why does my serial monitor connection crash whenever I get this code?

I also keep getting these:

0000168444 [system] ERROR: Cloud: unable to resolve IP for 260032000c51343334363138.udp.particle.io

0000168444 [system] WARN: Cloud socket connection failed: -1

I also get this:

0000090407 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 0

0000090507 [comm.protocol] ERROR: Event loop error 3

0000090507 [system] WARN: Communication loop error, closing cloud socket

0000090607 [system] INFO: Cloud: connecting

CAN ANYONE shed some light on any of these messages?

Note: if I unplug the USB cable to my PC and plug it back in the serial connection is re-established for a time until the handshake error message comes back.

I think I may have solved my problem.

Looks like it was because I was passing the address of an int to the cloud with Particle.variable instead of the int itself.

I changed this line of code:

Particle.variable("chargeBal", &packManager.chargeBalance);

to this:

Particle.variable("chargeBal", packManager.chargeBalance);

and now things seem to be working.

So to anyone else getting these strange errors when trying to connect to the cloud, take a look at your Particle.variable() calls and make sure they are using the new-school parameter types (actual variables being passed instead of addresses to variables).


I’d still like to know what the above error codes mean. I tried doing a search on the Particle Firmware repo on github for “handshake failed with code” and believe it is originating from the system_task.cpp file… but I’m really not sure what to make of the contents of that file… looks like it is some kind of RTOS thread controller code.

Another point to consider.
When your code is not behaving how you expect it, don’t just report the symptoms but also the code itself :wink:

1 Like