nim-chronos
nim-chronos copied to clipboard
crash when calling req.closeWait()
Hi, please forgive me if i misunderstood something really basic that makes this issue; i am trying to do a simple get request and the application is crashing
proc getipv4*(): string =
var session = createSession(true)
# let address = initTAddress("api.ipify.org:443")
let address = resolveTAddress("api.ipify.org",443.Port,Domain.AF_INET)[0]
let ha = getAddress(address, HttpClientScheme.Secure, "/")
var req = HttpClientRequestRef.new(session, ha, MethodGet)
let response = waitFor fetch(req)
if response.status == 200:
let data = cast[string](response.data)
result = data
else:
result = "fail"
waitFor(req.closeWait()) #crash happens at this line with msg 'Future operation cancelled!'
waitFor(session.closeWait())
log:
terminate called without an active exception Traceback (most recent call last) C:\....\server.nim(68) server C:\...\nettools.nim(35) getipv4 C:\....\nimble\pkgs\chronos-3.0.11\chronos\asyncloop.nim(1203) waitFor C:\....\nimble\pkgs\chronos-3.0.11\chronos\asyncloop.nim(295) poll C:\....\nimble\pkgs\chronos-3.0.11\chronos\asyncsync.nim(372) popFirst SIGABRT: Abnormal termination.