I am running a small web application on Raspberry Pi 2 (OS latest Raspbian, and no overclocking, samba installed) which runs on Apache, PHP, and MySQL.

The web app lets users punch a simple tickets for entry. The tickets once punched need to be printed automatically as well.

For this, I run a .NET install able application that runs on a computer on network, and calls http://raspberrypi/print_ticket_xml.php file every second to get XML formatted data, which the application parses and prints.

While running the application however, I have observed frequent time out issues on the C# application. I also track the execution time of PHP script - which is less than a second (0.014 or so)

  • How can I reduce network timeouts?
  • Is there a way to optimize network performance of Raspberry PI?
  • How can I measure/monitor what is consuming resources on Pi?
  • Why every second? This is going to be a massive overhead on any application even on local network. Maybe the PHP executes quickly but the TCP/IP stack add more overhead. – Piotr Kula May 9 '15 at 19:00

I suggest you run something like tshark or wireshark on the Pi.

sudo apt-get install wireshark

That will sniff network traffic and you'll be able to see the time taken between the incoming and outgoing network message.

I expect you'll discover the problem is at the other computer.


You can use the free Fiddler 4 on the Windows machine where your .NET client application is running to check what is happing with TCP/IP calls. If its a FORM/XAML app it will work straight away. If its a Web Application use Explorer as it needs to run through the Fiddler Proxy and IE, surprisingly works straight away.

It is quite possible your design may need to be reconsidered. In all the years of developing I never needed to do 1 seconds requests, all the time. Over 95% of the requests are possibly redundant. What ever it is you are doing, there has to be a better way to trigger the way data gets sent and I doubt it is a resource problem, its just a design flaw.

From what it seems, it looks like you need to print something when a user completes a task. So possibly, instead of the .NET app polling the Pi every second, reverse the role, send a request from the Pi to the .NET application once the task is complete. This eliminate the connection problem.

1 second polling is never a good approach. On a normal Windows machines (non server) there are limiters that cause requests to time out and possibly fail.

If you really need real time data for some reason it would be best to use SignalR (or Node.JS). It creates a socket and keeps the TCP/IP connection open, and you can then stream messages to many clients, instantly. It is really great and easy (I admit, there is an initial learning curve, but its worth it) Again, on a desktop Windows machine connections are limited to 10 (tweak-able in registry)

If you care to expand slightly on what it is you are doing I would be glad to help you with some more architectural advice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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