1

I'm running a distant HTTP server, serving a single page, used for delay measurements purposes. From my client, I'm generating multiple different custom circuits each being assigned a new upcoming stream.

Each stream is generated using python and stem to call in a multithreaded fashion torsocks as a wrapper for httping with the following call: 'torsocks -d httping -h xxx.yyy.xxx.yyy -p 80 -t 130 -c 1 -M with xxx.yyy.xxx.yyy being the IPv4 adress of my server.

My issue is the vast majority of them timeout (more than 90%), apparently between torsocks and the tor Controller, when generating few dozens of similar concurrent requests (totaling less than 100kB/s).

The -d debug flag's output of torsocks yield:

1615247437 DEBUG torsocks[39279]: [fclose] Close caught for fd 3 (in tsocks_fclose() at fclose.c:45)
1615247437 DEBUG torsocks[39279]: [onion] Pool init with subnet 127.42.42.0 and mask 24 (in onion_pool_init() at onion.c:103)
1615247437 DEBUG torsocks[39279]: [onion] Pool initialized with base 0, max_pos 255 and size 8 (in onion_pool_init() at onion.c:131)
1615247437 DEBUG torsocks[39279]: [getaddrinfo] Requesting xxx.yyy.xxx.yyy hostname (in tsocks_getaddrinfo() at getaddrinfo.c:44)
1615247437 DEBUG torsocks[39279]: [getaddrinfo] Node xxx.yyy.xxx.yyy will be passed to the libc call (in tsocks_getaddrinfo() at getaddrinfo.c:110)
1615247437 DEBUG torsocks[39279]: [socket] Creating socket with domain 2, type 1 and protocol 6 (in tsocks_socket() at socket.c:32)
1615247437 DEBUG torsocks[39279]: Connect caught on fd 3 (in tsocks_connect() at connect.c:118)
1615247437 DEBUG torsocks[39279]: [connect] Socket family AF_INET and type 1 (in tsocks_validate_socket() at connect.c:76)
1615247437 DEBUG torsocks[39279]: [onion] Finding onion entry for IP xxx.yyy.xxx.yyy (in onion_entry_find_by_addr() at onion.c:267)
1615247437 DEBUG torsocks[39279]: Connecting to the Tor network on fd 3 (in tsocks_connect_to_tor() at torsocks.c:473)
1615247437 DEBUG torsocks[39279]: Setting up a connection to the Tor network on fd 3 (in setup_tor_connection() at torsocks.c:368)
1615247437 DEBUG torsocks[39279]: Socks5 sending method ver: 5, nmethods 0x01, methods 0x00 (in socks5_send_method() at socks5.c:228)
1615247437 DEBUG torsocks[39279]: Socks5 received method ver: 5, method 0x00 (in socks5_recv_method() at socks5.c:262)
1615247437 DEBUG torsocks[39279]: Socks5 sending connect request to fd 3 (in socks5_send_connect_request() at socks5.c:459)
1615247557 DEBUG torsocks[39279]: Socks5 received connect reply - ver: 5, rep: 0x06, atype: 0x01 (in socks5_recv_connect_reply() at socks5.c:518)
1615247557 ERROR torsocks[39279]: Connection timed out (in socks5_recv_connect_reply() at socks5.c:547)
1615247557 DEBUG torsocks[39279]: [close] Close caught for fd 3 (in tsocks_close() at close.c:33)

My torsocks config is default, as well as the torrc one.

As the Controller is documented as being thread safe, I'm having a hard time solving this timeout issue. How can I solve this huge share of timeouts issue ?

3
  • How many connections are you making? Your guard relay may be rate-limiting you. What method are you using for generating circuits, and are you attaching your streams to these circuits manually?
    – Steve
    Mar 11, 2021 at 5:02
  • Hi, thanks for your question. I'm making 25, 50 or 100 parallel connections with about the same ratio of timeouts. The circuits are manually generated by retrieving relay pool via Controller.get_network_statuses() then picking among the relays with a Running flag, I'm picking a Guard an Exit and a middle one, assembling them in a path and using Controller.new_circuit() to build it. Repeating until a valid circuit is successfully created. Each connection use a fully different circuit, avoiding to use the same Guard twice, and streams are attached manually, one stream per circuit.
    – luruel
    Mar 11, 2021 at 9:17
  • Was you able to discover something?
    – user109764
    Jun 26, 2022 at 1:17

0

You must log in to answer this question.

Browse other questions tagged .