0

I was working on an application where i have two tasks and which are interdependent

  1. Fetch some data from external server.
  2. Even if the internet gets disconnected can the same webpage call my flask application and call the GPIO?

For now, i am using uwsgi+flask+nginx and in this setup when internet is lost i get lot of errors like

Feb 17 18:05:39 raspberrypi uwsgi[1831]: DAMN ! worker 2 (pid: 2051) died :( trying respawn ...
Feb 17 18:05:39 raspberrypi uwsgi[1831]: Respawned uWSGI worker 2 (new pid: 2284)

Upstream prematurely closed connection while reading upstream

And when these errors come, my web application freezes and could not access the underlying flask application. But my application is running on localhost:8080 ip. But i don't know why it freezes when internet is disconnected.

When I disable the internet and host the same system on my mac, it's behaving as expected. I do not understand why it is failing on Raspberry Pi.

Is there anyway i could deploy my flask application even when internet is disconnected i could do the local tasks. By searching online i found out few web-servers

  1. Twisted
  2. Apache
  3. gunicorn
  4. Tornado

Please help me with this.

  • have you tried to disable the first task to see if the external data fetch may be causing the problem? – jsotola Feb 18 at 6:50
  • Where exactly is the problem with Raspberry Pi? Can't find it. – Ingo Feb 18 at 13:15
  • @Ingo Here when i disable the internet and host the same system on my mac, it's behaving as expected. But on raspberry it's behaving differently as mentioned above – Shoaib Mohammed Feb 18 at 17:42
  • @jsotola Yes, external data fetch is smooth when internet is connected and uwsgi responds properly. But when internet goes down and comes back uwsgi gives the mentioned errors and take 1 min 10 secs to comeback and then it starts hosting the flask application. – Shoaib Mohammed Feb 18 at 17:47
  • Would you mind adding which distro you're running and whether this also happens when bound to 0.0.0.0:8000? – isaacparrot Feb 18 at 21:03

Your Answer

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

Browse other questions tagged or ask your own question.