TCP server and client between two photons


Maybe I need a full version of your code to thoroughly estimate your problem. :smiley:


That’s an interesting find.
Once you’ve gathered your background info, could you please open an issue on GitHub about your find with a reference to this thread and your test code?


I’m going to simplify my server and client down to the minimum to see where the problem lies.
And see if I still get the problem ,and how many connection it takes before I get a error.


this is my very basic server ripped from my code which works about 1500 before going wrong.


int led1 = D7;

TCPServer server = TCPServer(80);
TCPClient client;

void setup()

void loop()

if ( WiFi.ready() )
      if (client.connected() )
              char c;
              Serial.println("Some as connected");
              IPAddress clientIP = client.remoteIP();
              while ( client.available() )
                    c =;
                    Serial.print( c );
              client = server.available();
  digitalWrite(led1, HIGH);
  digitalWrite(led1, LOW);

and this works once if i`m lucky , something is wrong with TCPserver / client.
the more you cut out the less it works.

the client

// ===================================================
String cubie_str;
TCPClient client;
byte server[] = { 192, 168, 0, 80 };
int port = 80;
// ===================================================

void server_loop()
  client.connect(server, port);
    if ( client.connected() == TRUE )
          cubie_str = String(counter);
          client.print( cubie_str );

which is code via a one second software timer


I suggest you to print out through the serial port these statuses: client.connect(),client.available(),and in the server client.remoteIP() to see how they go.


The client’s and server’s receive buffers may take up a little while to fill up after the client connects to the server, so you should put a

while(client.available()<0) Particle.process();

immediately after

 if (client.connected() )

in my humble opinion.


Hi particle_Adam,

I am very interested in this topic.
I am actually a student and beginner with the Particle photon.
can you give me some Details if you want to do a connection between a client which should be our particle and a server located in my local network.?
how to open a connection between the particle and the server that should be built (in java or C) on my computer ?

thank you in advance.


Hello, as you mentioned that you are working on 2 clients connected with a server and communicating with each other. i am interested to do that project. can you please send me the codes. so that i can work on the hardware part.

Thanks in advance