When posting data with httpclient I get the following error:
    
    
    : unhandled exception: No connection could be made because the target 
machine actively refused it.
    
    Run

Two code examples, the first straight from the docs:
    
    
    var client = newHttpClient()
    var data = newMultipartData()
    data["output"] = "soap12"
    data["uploaded_file"] = ("test.html", "text/html",
      "<html><head></head><body><p>test</p></body></html>")
    
    echo client.postContent("192.168.1.4:8088", multipart=data)
    
    
    Run

or even simpler
    
    
    import httpclient
    
    var
      posterClient = newHttpClient()
      ok = true
      res: Response
    
    while ok:
      res = posterClient.post("192.168.1.4:8088/echo/")
      sleep(1000)
    
    
    Run

The server code:
    
    
    import prologue
    
    proc echoPost(ctx: Context) {.async.} =
      echo ctx.request
      resp ""
    
    let
      env = loadPrologueEnv(".env")
      settings = newSettings(
        debug = true,
        address = env.getOrDefault("address", "192.168.1.4"),
        port = Port(env.getOrDefault("port", 8088))
      )
    
    var app = newApp(settings = settings)
    app.addRoute("/echo", echoPost, HttpPost)
    app.run()
    
    
    Run

All apps have proper permissions in the firewall (Win10). A simple python 
"poster" works flawless:
    
    
    import time
    import random
    import requests
    
    def rndtoport():
        time.sleep(2)
        url = 'http://192.168.1.4:8088/echo'
        print(f'posting random data to {url}')
        while True:
            time.sleep(random.random() * 2)
            r = requests.post(url)
            print(r.headers, r.status_code)
    
    rndtoport()
    
    
    Run

Whats wrong / going on?

Reply via email to