Maybe I need a full version of your code to thoroughly estimate your problem.
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.
//SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(AUTOMATIC);
int led1 = D7;
TCPServer server = TCPServer(80);
TCPClient client;
void setup()
{
Serial.begin(9600);
pinMode(led1,OUTPUT);
server.begin();
}
void loop()
{
if ( WiFi.ready() )
{
if (client.connected() )
{
char c;
Serial.println("Some as connected");
IPAddress clientIP = client.remoteIP();
Serial.println(clientIP);
Serial.println(WiFi.localIP());
while ( client.available() )
{
c = client.read();
Serial.print( c );
}
Serial.println("");
client.stop();
}
else
{
client = server.available();
}
}
Particle.process();
digitalWrite(led1, HIGH);
delay(500);
digitalWrite(led1, LOW);
delay(500);
}
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 )
{
client.flush();
cubie_str = String(counter);
client.print( cubie_str );
toggle_led();
}
}
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