-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crash when calling req.closeWait() #345
Comments
Your source is a bit incomplete, imho. import chronos
import chronos/apps/http/httpclient
proc getipv4*(): string =
var session = HttpSessionRef.new()
# 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())
when isMainModule:
echo getipv4() on both Linux and Windows with latest
If you modify your source to this import chronos
import chronos/apps/http/httpclient
proc getipv4*(): string =
var session = HttpSessionRef.new()
# let address = initTAddress("api.ipify.org:443")
let address = session.getAddress("https://api.ipify.org").valueOr:
echo "Could not resolve address api.ipify.org with error"
echo error
return ""
var req = HttpClientRequestRef.new(session, address, 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())
when isMainModule:
echo getipv4() you will be able to see your IP address. What version of Nim do you use? |
Thankyou for your answer |
after furthur tests , i understood that when i compile with C backend, everything works fine as expected |
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
log:
The text was updated successfully, but these errors were encountered: