curl / Mailing Lists / curl-library / Single Mail

curl-library

Proxied CURL socket closing prematurely

From: Neil Canham <neil_at_knowsense.co.uk>
Date: Sat, 21 Apr 2018 14:37:40 +0100

Hi
  I have a Windows application that tunnels data through a proxy server.
The application was previously written using raw sockets. However in order
to allow authentication with NTLM proxies we have updated it to use libcurl
to perform the initial HTTP CONNECT and then continue to use the resulting
socket for the transfer as we did before.

This is mostly working very well, however we find that when transferring
more than around 65-70k bytes the tunnelled socket closes of its own
accord. Wireshark shows that the final packet sent has its FIN flag set.
There is more data to be sent, and our code has not closed the socket.

relevant code is (with error handling removed):

CURLcode res;
curl_socket_t sockfd;

curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, my_trace);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curlErrors);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_setopt(curl, CURLOPT_URL, ServerHost);
curl_easy_setopt(curl, CURLOPT_PORT, (long) ServerPort);
res = curl_easy_setopt(curl, CURLOPT_PROXY, ProxyHost);
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_easy_setopt(curl, CURLOPT_PROXYPORT, (long) ProxyPort);

res = curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_NTLM_WB |
CURLAUTH_NTLM);
res = curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, ":");

curl_easy_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1);
res = curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1);
res = curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
res = curl_easy_getinfo(curl, CURLINFO_ACTIVESOCKET, &sockfd);

loop.. read from client, write to sockfd

Any thoughts on why it might be closing the connection early, or how I can
find out more?

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-04-21