www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.net.curl.CurlException Couldn't resolve host name on handle

reply Vino <akashvino79 gmail.com> writes:
Hi All,

   Request your help, the below code is fetching the required 
data, after fetching the data at the end it throws the below 
errors , hence request your help on how to handle this issue.

Code:

import std.net.curl, std.stdio, std.conv: to;

void main () {
auto http = HTTP();
http.handle.set(CurlOption.userpwd, "test:password");
http.handle.set(CurlOption.connecttimeout, 300);
http.handle.set(CurlOption.timeout, 600);
http.handle.set(CurlOption.tcp_nodelay, 1);
http.handle.set(CurlOption.buffersize,1073741824);
http.handle.set(CurlOption.url, "https://test:8130/sdata");
http.method(HTTP.Method.get);
auto content = http.perform();
http.shutdown;
foreach (line; byLine(to!string(content)))
writeln(line);
}

Error
std.net.curl.CurlException std\net\curl.d(4364): Couldn't resolve 
host name on handle BC9A90
----------------
0x004032AF
0x00403258
0x00408A34
0x00408890
0x00403F89
0x00403046
0x004023E8
0x0041A073
0x00419FED
0x00419E88
0x00413EBA
0x0040B18B
0x74EE6359 in BaseThreadInitThunk
0x77227B74 in RtlGetAppContainerNamedObjectPath
0x77227B44 in RtlGetAppContainerNamedObjectPath

From,
Vino.B
Mar 13 2020
parent reply Vino <akashvino79 gmail.com> writes:
On Friday, 13 March 2020 at 18:10:51 UTC, Vino wrote:
 Hi All,

   Request your help, the below code is fetching the required 
 data, after fetching the data at the end it throws the below 
 errors , hence request your help on how to handle this issue.

 Code:

 import std.net.curl, std.stdio, std.conv: to;

 void main () {
 auto http = HTTP();
 http.handle.set(CurlOption.userpwd, "test:password");
 http.handle.set(CurlOption.connecttimeout, 300);
 http.handle.set(CurlOption.timeout, 600);
 http.handle.set(CurlOption.tcp_nodelay, 1);
 http.handle.set(CurlOption.buffersize,1073741824);
 http.handle.set(CurlOption.url, "https://test:8130/sdata");
 http.method(HTTP.Method.get);
 auto content = http.perform();
 http.shutdown;
 foreach (line; byLine(to!string(content)))
 writeln(line);
 }

 Error
 std.net.curl.CurlException std\net\curl.d(4364): Couldn't 
 resolve host name on handle BC9A90
 ----------------
 0x004032AF
 0x00403258
 0x00408A34
 0x00408890
 0x00403F89
 0x00403046
 0x004023E8
 0x0041A073
 0x00419FED
 0x00419E88
 0x00413EBA
 0x0040B18B
 0x74EE6359 in BaseThreadInitThunk
 0x77227B74 in RtlGetAppContainerNamedObjectPath
 0x77227B44 in RtlGetAppContainerNamedObjectPath

 From,
 Vino.B
Hi All, I was able to resolve this issue by upgrading DMD from V88 to V91.0, and now I am getting the below error when i set any of the below options http.handle.set(CurlOption.ipresolve, "v4"); http.handle.set(CurlOption.http_version, "v1_1"); http.handle.set(CurlOption.sslversion, "sslv3"); Error: std.net.curl.CurlException std\net\curl.d(4388): A libcurl function was given a bad argument on handle CF2990 ---------------- 0x0040B425 0x00402397 0x00406E17 0x00406D91 0x00406C2A 0x0040404A 0x0040242F 0x75BC6359 in BaseThreadInitThunk 0x77BB7B74 in RtlGetAppContainerNamedObjectPath 0x77BB7B44 in RtlGetAppContainerNamedObjectPath from, Vino.B
Mar 13 2020
next sibling parent Andre Pany <andre s-e-a-p.de> writes:
On Saturday, 14 March 2020 at 04:24:20 UTC, Vino wrote:
 On Friday, 13 March 2020 at 18:10:51 UTC, Vino wrote:
 [...]
Hi All, I was able to resolve this issue by upgrading DMD from V88 to V91.0, and now I am getting the below error when i set any of the below options http.handle.set(CurlOption.ipresolve, "v4"); http.handle.set(CurlOption.http_version, "v1_1"); http.handle.set(CurlOption.sslversion, "sslv3"); Error: std.net.curl.CurlException std\net\curl.d(4388): A libcurl function was given a bad argument on handle CF2990 ---------------- 0x0040B425 0x00402397 0x00406E17 0x00406D91 0x00406C2A 0x0040404A 0x0040242F 0x75BC6359 in BaseThreadInitThunk 0x77BB7B74 in RtlGetAppContainerNamedObjectPath 0x77BB7B44 in RtlGetAppContainerNamedObjectPath from, Vino.B
The value for CurlOption.http_version is wrong. A number is expected here. Unfortunately the constants are not in Phobos yet. If I remember correctly, please pass the value 4 as work around. For the other options I am not sure, maybe they also expects numbers instead of strings. Kind regards Andre
Mar 13 2020
prev sibling parent Vino <akashvino79 gmail.com> writes:
On Saturday, 14 March 2020 at 04:24:20 UTC, Vino wrote:
 On Friday, 13 March 2020 at 18:10:51 UTC, Vino wrote:
 Hi All,

   Request your help, the below code is fetching the required 
 data, after fetching the data at the end it throws the below 
 errors , hence request your help on how to handle this issue.

 Code:

 import std.net.curl, std.stdio, std.conv: to;

 void main () {
 auto http = HTTP();
 http.handle.set(CurlOption.userpwd, "test:password");
 http.handle.set(CurlOption.connecttimeout, 300);
 http.handle.set(CurlOption.timeout, 600);
 http.handle.set(CurlOption.tcp_nodelay, 1);
 http.handle.set(CurlOption.buffersize,1073741824);
 http.handle.set(CurlOption.url, "https://test:8130/sdata");
 http.method(HTTP.Method.get);
 auto content = http.perform();
 http.shutdown;
 foreach (line; byLine(to!string(content)))
 writeln(line);
 }

 Error
 std.net.curl.CurlException std\net\curl.d(4364): Couldn't 
 resolve host name on handle BC9A90
 ----------------
 0x004032AF
 0x00403258
 0x00408A34
 0x00408890
 0x00403F89
 0x00403046
 0x004023E8
 0x0041A073
 0x00419FED
 0x00419E88
 0x00413EBA
 0x0040B18B
 0x74EE6359 in BaseThreadInitThunk
 0x77227B74 in RtlGetAppContainerNamedObjectPath
 0x77227B44 in RtlGetAppContainerNamedObjectPath

 From,
 Vino.B
Hi All, I was able to resolve this issue by upgrading DMD from V88 to V91.0, and now I am getting the below error when i set any of the below options http.handle.set(CurlOption.ipresolve, "v4"); http.handle.set(CurlOption.http_version, "v1_1"); http.handle.set(CurlOption.sslversion, "sslv3"); Error: std.net.curl.CurlException std\net\curl.d(4388): A libcurl function was given a bad argument on handle CF2990 ---------------- 0x0040B425 0x00402397 0x00406E17 0x00406D91 0x00406C2A 0x0040404A 0x0040242F 0x75BC6359 in BaseThreadInitThunk 0x77BB7B74 in RtlGetAppContainerNamedObjectPath 0x77BB7B44 in RtlGetAppContainerNamedObjectPath from, Vino.B
Hi All, Was able to resolve the above issue, but need your advice as to whether i thoughts are correct. ipresolve: The document(crul.d) for the ipresolve states the type as enum CurlIpResolve: int; enum CurlIpResolve { whatever = 0, /** default, resolves addresses to all IP versions that your system allows */ v4 = 1, /** resolve to ipv4 addresses */ v6 = 2 /** resolve to ipv6 addresses */ } Solution: so I added the line "http.handle.set(CurlOption.ipresolve, 1);" for ipv4 http_version: The document(crul.d) for the http_version states the type as enum http_version int enum CurlHttpVersion { none, /** setting this means we don't care, and that we'd like the library to choose the best possible for us! */ v1_0, /** please use HTTP 1.0 in the request */ v1_1, /** please use HTTP 1.1 in the request */ last /** *ILLEGAL* http version */ } Solution: so I added the line "http.handle.set(CurlOption.http_version, 2);" for v1_1, not sure whether this is correct as it is not mentioned just followed the same rule of ipresolve. sslversion: The document(crul.d) for the sslversion states the type as enum CurlSslVersion: int; enum CurlSslVersion { default_version, /// tlsv1, /// sslv2, /// sslv3, /// last /** never use */ } Solution: so I added the line "http.handle.set(CurlOption.sslversion, 4);" for sslv3, not sure whether this is correct as it is not mentioned just followed the same rule of ipresolve. From, Vino.B
Mar 13 2020