TCPClient.connect causes system resets with 0.5.0 but not 0.4.9

This is from a different feed - but I wasn’t sure if SOLVED topics are still looked at. Sorry if double posting!

I’m getting a system reset with 0.5.0 everytime I attempt to connect to as a TCP client to a tested server

I call this function on a device from the command line

int dataLoad(String args) {
  byte server333[] = { 54, , ***, }; 
  client.connect(server333, 8000);

  if (waitFor(client.connected, 5000)) {
    client.stop();
    return 200;
  } else {
    return 404;
  }
}

And the device restarts after a short timeout with no returns. I’m able to netcat a TCP connection without a problem and my server never sees a connection from the P1.

As soon as I reverted to 0.4.9, it worked without a hitch - returns 200 with the server picking up the connection from the P1. No other changes in code

I haven’t had any luck reproducing this yet. I tried the code in the other post and I’m getting a 200 back, and no faults when I call the dataLoad function. The Photon is running 0.5.0-rc2. I tried with the app built against 0.5.0-rc2, and just out of curiosity I also tried an app built for 0.4.9 but running on 0.5.0-rc2 and both worked properly for me.

Thanks for checking that out, I’ll fire up a photon and give it a shot

I actually had no problem with a Photon on either 0.5.0 or 0.4.9. I’ll revert back to

if (client.connect(server333, 8000) {

} else {

}

as suggested

I think this is either something with a P1 or something with our particular setup . As soon as I ran this on a pared down program on our device (P1), I got the same problem

So after a lot of trial and error narrowed the issue down to one call in 0.5.0 - pinMode

The below code does not work when calling dataLoad on 0.5.0 on either a photon or a p1, but does work on 0.4.9. I’m getting and SOS signal on the photon as soon as the call is made showing 1 flashing red (hard fault). Also, it doesn’t seem to matter what pin

 #include "application.h"

SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);

TCPClient client;

int dataLoad(String args) {
  byte server333[] = { 54, XX, XX, XXX }; 
  if (client.connect(server333, 8000)) {
   client.stop();
    return 200;
  } else {
    return 404;
  }
}

bool print = false;

void setup(){
  Particle.function("dataLoad", dataLoad);
  Particle.connect();
  pinMode(A1, INPUT);
}


void loop() {
  if (Particle.connected() && !print) {
    print = true;
    Particle.publish(String(System.version()), "Hello10");
  }
}

That pinMode() should be the reason does not seem very likely. I’d rather suspect some other thing going on in the background.
So could you disable system threading for testing?
Also could you specify if you are using 0.5.0-rc.1 or -rc.2 - as @rickkas7 already mentioned -rc.2 has a specific bug fix already.

I ran the code above, only changing the IP address and port to a valid local server IP address and port. Tested with a Photon running 0.5.0-rc2 and I’m still getting a 200 response to a dataLoad function call, and no faults. Mysterious!

I feel like I’m taking crazy pills on this, thanks for taking a look. ScruffR completely agree, I’m using 0.5.0-rc.2 and I’m flashing to the device with the $ particle flash YOUR_DEVICE_NAME system-part1-0.5.0-rc.2-p1.bin in two parts.

Have you gotten it to work on any remote server? I can give you mine if need be.

Thanks again

I just tried a non-local server and it’s still working; getting a 200 back.

I wish there was a video recording of my debugging session yesterday because I have not changed a thing and now it’s working like clockwork. Perhaps something with how I was flashing 0.5.0. I’m happy that it’s working but completely confused. Thanks @ScruffR, @rickkas7, and @mdma!

I’ll let you know if there are any changes but so far so good!

P.S. this is likely our last pre-production hold-up so double thanks

1 Like