I have made a simple server using the YUN SERVER and CLIENT Libraries./ The server runs on a loop and waits for a client to connect. After connection it sends the client a simple message and then disconnects the client.

#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>

#define PORT 6666
YunServer server(PORT);
int pin =13;

void setup() {
void loop() {
  YunClient client = server.accept();
void startup_msg(YunClient client)

Well this code runs smoothly for few hours. But after that, it stops responding to any client request. I guess the server crashes. I have to restart the YUN to get it working again.

Is there anyway I can run this without it getting to crash? Well I want it to be running just like a normal server would.

1 Answer 1


Updating your YUN might solve this problem. It is recommended to update it after you buy it because they usually come with old firmware. Make sure its up to date. Here a link on how to do this

Another thing to try is to add delay(50); at the end of the loop() function. It prevents the processor from doing lots of work.

  • My YUN is upgraged to the latest firmware, and if you closely see the inside loop() there is already a delay of 500ms. Anyway, I am just confused. It is suppose to behave like a server without any hassle. But its not. Mar 15, 2015 at 5:20
  • I just noticed that. Maybe 500 millisecond is too much delay. 50 milliseconds is recommended on the Arduino website. I would be happy to fix this easily by running it on my side here but I don't have YUN. I have Uno and Mega. It looks like you are writing HIGH to pin 13 without making it OUTPUT. Assuming your goal is to turn on the led connected to pin 13, you should first make the pin OUTPUT once in the "setup()" function. pinMode(pin,OUTPUT); Also comment or remove Serial.begin(115200); to see if that is the problem. Finally, is this the whole code you are having problem with?
    – Programmer
    Mar 15, 2015 at 6:45
  • Thanks for your insights! Really helpful! Well, i removed Serial.begin(115200) and set the pin 13 to output. Now I just have to test this for few hours and see if it stays put without crashing. And yes, this is the basic code I have now, but will be developing it for further work. Just needed to know if this was stable before proceeding! Mar 15, 2015 at 7:14
  • Ok. Let me if it stops working again.
    – Programmer
    Mar 15, 2015 at 9:29
  • It has been over 24 hours. Did it work?
    – Programmer
    Mar 16, 2015 at 20:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.