Flask Application with wSGI and Nginx not working properly

September 27, 2018 820 views
Ubuntu Nginx Applications Python Deployment

I followed the https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-16-04 tutorial which went smoothly. I am running a simple blockchain type application where you can POST some data to the application and it returns, a transaction record for you.
This worked well on my development server, for as long as I kept it running - I could always send some data and get a response.

I am new to development, so I could have my entire approach wrong, but I assumed that if the script worked fine on the development server, it would also work once deployed.
I have deployed it to https://blockchain.tatiblockchain.co.za
It is not a website so you won’t find anything on the “/” route. But if you go to “/getchain” you should get the current chain stored.

If you go to “/addtransaction” - you should POST a json-object and the fields of that object will be added to the transactions on the server, until they are mined - then they should be added to the chain.

My problem is this - when I call my routes, I get inconsistent results. Sometimes I get a chain back, sometimes a longer one - sometimes I get just a block. The data seems to disappear and re-appear. If the server was not working at all - I should get nothing, but I get wrong data sent back to me, old data or data from the wrong block etc.
It just does not behave the way the development server behaved.

This is an example Below:
try https://blockchain.tatiblockchain.co.za/addtransaction and post

{
"name": "Name Surname"
}

Then call https://blockchain.tatiblockchain.co.za/gettransactions - I am supposed to get that added to the pool. Sometimes I get nothing, sometimes I get it back, sometimes I get old transactions back - I know I have already cleared.

I am using postman to test this.

I have tried - searching for solutions, re-deploying. My dev server works just fine, not the production server.
Should I just leave my application on the development server, I don’t expect to get a lot of requests anyway - because this was just a test project for illustration on another website - I just wanted it hosted online, so I could call it from any computer.

2 Answers

Problem solved, how do I delete this question?

  • Hello. Instead of delete the question, please, show us how did you solved! I’m having the same problem.

Please, how did you solve your issue. Having the same issue. This time with gunicorn and nginx.

Have another answer? Share your knowledge.