0

I'm doing the following request in curl:

curl --connect-timeout 2000 -d MY_JSON -H "Content-Type: application/json" -X POST MY_ADDRESS. 

After 20 minutes the server sends it's response and that works perfectly. But when I tried in python, it didn't work with the following code:

import requests
data=MY_JSON
requests.post(MY_ADDRESS, json=data, headers={'Content-Type' : 'application/json'}) 

I can see in the logs of the server that it sent a response but it doesn't look like the client is aware of that

I tried with different timeout and tried to add verify=False, tried to add another header, Accept, but it still didn't work

Requests did work when the response was under 10 minutes or so

10
  • If you have control over the server can you arrange for a response to be returned in a more timely fashion in order to try to eliminate timing issues? Commented Feb 13, 2023 at 6:42
  • If you wrote the server, why not use websocket? Commented Feb 13, 2023 at 6:53
  • It doesn't look like you are actually capturing the response, unless it's not a whole code? You can try to print/log the response on the client side, add raise_for_status to see if some network error doesn't occur. Commented Feb 13, 2023 at 7:00
  • @Pingu, I'm not sure that I understand. What do you want me to try? Commented Feb 13, 2023 at 7:11
  • @WakemeUpNow I'm not sure how to use them, the server side is a simple flask server in python Commented Feb 13, 2023 at 7:12

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.