Picture of lag
Registered 5 years 208 days
lag Tuesday, 12 November 2019, 02:41 PM
http Client
The following lines of code:

IHTTPClient* httpClient = IHTTPClient::Create(iomux, service->localSocketProvider, nullptr, this, this);
httpClient->Connect("http://lag-10.jtel.local:8091");

always result in this:

1-12 13:34:54.846 jtelrouter@jtel.de HTTPClient(0011e5a0,001151c0)::Connect address:http://lag-10.jtel.local:8091 usersadnull) pwd:00000000 authMethods:0
11-12 13:34:54.851 jtelrouter@jtel.de Dns(0011e5a8)::GetHostByName hostName:lag-10.jtel.local
11-12 13:34:54.989 jtelrouter@jtel.de Dns(0011e5a8)::GetHostByNameResult addr:10.42.15.16 isIPv6:0
11-12 13:34:54.989 jtelrouter@jtel.de HTTPClient(0011e5a0,001151c0)::HTTPClientShutdown reason:HTTP_CONNECT_FAILED
11-12 13:34:54.989 JTELRouter::HTTPClientShutdown(HTTP_CONNECT_FAILED)
11-12 13:34:54.989 jtelrouter@jtel.de HTTPClient(0011e5a0,001151c0)::~HTTPClient
1

According to wireshark, the app platform never attempts to open a TCP socket to the webserver.

Using port 80, supplying no port in the URI, or supplying the IP address directly does not change this behaviour.

Questions:

Why is the http client not attempting to connect? Is something on the app platform maybe not configured correctly? (Everything else appears to be working OK).

CreateLocalSocketProvider() --> can the returned socket be used more than once?

CreateTLSSocketProvider() --> what is the correct way to setup this?

Thanks

Lewis
Picture of Daniel Deterding (innovaphone)
Moderator Registered 15 years 178 days
Daniel Deterding (innovaphone) Tuesday, 12 November 2019, 03:00 PM
Re: http Client
Hi Lewis,

you handed the local socket provider to the HTTP client, which can't be used to establish connections outside of the linux.

You must create a TLS and TCP socket provider in your main cpp file like this:
ISocketProvider * localSocketProvider = CreateLocalSocketProvider();
ISocketProvider * tcpSocketProvider = CreateTCPSocketProvider();
ISocketProvider * tlsSocketProvider = CreateTLSSocketProvider(tcpSocketProvider);

and hand these references to your service class and afterwards to the http client:
IHTTPClient::Create(iomux, service->tcpSocketProvider, service->tlsSocketProvider , this, this);

Greetings,
Daniel
Picture of lag
Registered 5 years 208 days
lag Tuesday, 12 November 2019, 03:11 PM
Re: http Client
PERFECT. Works, thanks!
← You can define your color theme preference here