title: Python Requests ConnectionError: ('Connection aborted.', ConnectionResetError(10054)
body: <p>I try to send a image to Azure virtual machine and get a message.
  Server code:</p>
  
  <pre><code>from flask import Flask, request, Response
  import jsonpickle
  import numpy as np
  import cv2
  
  # Initialize the Flask application
  app = Flask(__name__)
  
  
  # route http posts to this method
  @app.route('/api/test', methods=['POST'])
  def test():
      r = request
      # convert string of image data to uint8
      nparr = np.fromstring(r.data, np.uint8)
      # decode image
      img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
  
      # build a response dict to send back to client
      response = {'message': 'image received. size={}x{}'.format(img.shape[1], img.shape[0])
                  }
      # encode response using jsonpickle
      response_pickled = jsonpickle.encode(response)
  
      return Response(response=response_pickled, status=200, mimetype="application/json")
  
  
  # start flask app
  app.run(host="0.0.0.0", port=5000)
  </code></pre>
  
  <p>Client code:</p>
  
  <pre><code>from __future__ import print_function
  import requests
  import json
  import cv2
  
  addr="http://azure_vm_ip:5000/"
  test_url = addr + '/api/test'
  
  # prepare headers for http request
  content_type = 'image/jpeg'
  headers = {'content-type': content_type}
  
  img = cv2.imread('image.jpg')
  # encode image as jpeg
  _, img_encoded = cv2.imencode('.jpg', img)
  # send http request with image and receive response
  response = requests.post(test_url, data=img_encoded.tostring(), headers=headers)
  # decode response
  print(json.loads(response.text))
  
  # expected output: {u'message': u'image received. size=124x124'}
  </code></pre>
  
  <p>I am getting this error: <code>ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))</code></p>
  
  <p>I can run the same code at my localhost and works fine. But this doesn't work at VM.
  What do I do wrong?</p>