I have the following routes:
@app.route("/item/{item_id}", methods=['GET'])
def view_item(item_id):
return
When I run chalice local
If I view the page on browser(GET), works fine, but then using POSTMAN to get to the page, I endup with endless wait, but GET on browser still works
restarts chalice local
If I use POSTMAN to GET to the page first, it works, then GET page on browser doesn't work, but POSTMAN GET still works.
Interesting. I just tested and had the same experience. If I go to the terminal running chalice and send a ctrl + c it then returns in whichever second process was started. Somehow the first request is blocking the second request.
It also only seems to happen when the browser becomes involved. Switching between curl and postman doesn't cause an issue for me.
Intersting. My guess is that the browser is opening multiple connections at once for efficiency. Probably looking for a favicon.ico due to the GET and this ties up the single threaded http server. I'm not positive though so I will investigate.
Followed up with this, my initial guess was not correct. The reason was simply that when you perform a GET with a browser it holds the connection open, when you close it from the server side it reopens it. So the only request that will go through is the next one from that same socket which the browser reuses. The default http server behavior in Python is to have no timeout on sockets so it will just sit there blocked forever if the browser is closed. I will try to get this fixed shortly.
You will get API results via Postman if you define Content-Type: application/json or Content-Type: application/javascript.
Other than this please make sure you are calling out right operation i.e. "PUT"/"GET"
Most helpful comment
Followed up with this, my initial guess was not correct. The reason was simply that when you perform a GET with a browser it holds the connection open, when you close it from the server side it reopens it. So the only request that will go through is the next one from that same socket which the browser reuses. The default http server behavior in Python is to have no timeout on sockets so it will just sit there blocked forever if the browser is closed. I will try to get this fixed shortly.