help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Difference of packets sent via /dev/tcp to chromedriver and httpbin


From: Peng Yu
Subject: Difference of packets sent via /dev/tcp to chromedriver and httpbin
Date: Thu, 1 Apr 2021 21:27:55 -0500

Hi,

main_chromedriver.sh below hangs there. Does anybody know why? Details
are shown below.

I run a chromedriver locally at port 9515. (You can just download the
binary and run it locally. I tested on macOS)

https://chromedriver.chromium.org

When I run the following bash script,

$ cat main_chromedriver.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

{
    req_header=(
        "GET /sessions HTTP/1.1"
        "Connection: close"
    )
    builtin printf '%s\r\n' "${req_header[@]}" '' >&"$fd"
    while true; do
        IFS= read -u "$fd" -r line || return
        line=${line%$'\r'}
        [[ $line ]] || break
        builtin printf '%s\n' "$line"
    done
    sleep 1
    cat <&"$fd"
} {fd}<>/dev/tcp/127.0.0.1/9515

it prints something like this. And the script hangs.

HTTP/1.1 200 OK
Content-Length:37237
Content-Type:application/json; charset=utf-8
Connection:close
{"sessionId":"","status":0,"value":[{"capabilities":{"acceptInsecureCerts":false...

When I try to run basically the same script on httpbin.org, it won't
hang and finishes correctly.

$ cat ./main_httpbin.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

set -v
{
    req_header=(
        "GET /get HTTP/1.1"
        "Host: myhost"
        "Connection: close"
    )
    builtin printf '%s\r\n' "${req_header[@]}" '' >&"$fd"
    while true; do
        IFS= read -u "$fd" -r line || return
        line=${line%$'\r'}
        [[ $line ]] || break
        builtin printf '%s\n' "$line"
    done
    sleep 1
    cat <&"$fd"
} {fd}<>/dev/tcp/httpbin.org/80

Wireshark packet monitoring result for the chromedriver case looks
like the following. 61485 is the port used by bash. There is no FIN
packet sent by bash according to Wireshark.

  233  14.786045    127.0.0.1 → 127.0.0.1    TCP 68 61485 → 9515 [SYN]
Seq=0 Win=65535 Len=0 MSS=16344 WS=64 TSval=1457835670 TSecr=0
SACK_PERM=1
  234  14.786110    127.0.0.1 → 127.0.0.1    TCP 68 9515 → 61485 [SYN,
ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=16344 WS=64 TSval=1457835670
TSecr=1457835670 SACK_PERM=1
  235  14.786117    127.0.0.1 → 127.0.0.1    TCP 56 61485 → 9515 [ACK]
Seq=1 Ack=1 Win=408256 Len=0 TSval=1457835670 TSecr=1457835670
  236  14.786123    127.0.0.1 → 127.0.0.1    TCP 56 [TCP Window
Update] 9515 → 61485 [ACK] Seq=1 Ack=1 Win=408256 Len=0
TSval=1457835670 TSecr=1457835670
  237  14.786293    127.0.0.1 → 127.0.0.1    TCP 80 GET /sessions
HTTP/1.1  [TCP segment of a reassembled PDU]
  238  14.786303    127.0.0.1 → 127.0.0.1    TCP 56 9515 → 61485 [ACK]
Seq=1 Ack=25 Win=408256 Len=0 TSval=1457835670 TSecr=1457835670
  239  14.786309    127.0.0.1 → 127.0.0.1    HTTP 77 GET /sessions HTTP/1.1
  240  14.786312    127.0.0.1 → 127.0.0.1    TCP 56 9515 → 61485 [ACK]
Seq=1 Ack=46 Win=408192 Len=0 TSval=1457835670 TSecr=1457835670
  241  14.787515    127.0.0.1 → 127.0.0.1    TCP 16388 HTTP/1.1 200 OK
 [TCP segment of a reassembled PDU]
  242  14.787517    127.0.0.1 → 127.0.0.1    TCP 16388 9515 → 61485
[ACK] Seq=16333 Ack=46 Win=408192 Len=16332 TSval=1457835671
TSecr=1457835670 [TCP segment of a reassembled PDU]
  243  14.787519    127.0.0.1 → 127.0.0.1    HTTP 4734 HTTP/1.1 200 OK
 (application/json)
  244  14.787528    127.0.0.1 → 127.0.0.1    TCP 56 61485 → 9515 [ACK]
Seq=46 Ack=32665 Win=375616 Len=0 TSval=1457835671 TSecr=1457835671
  245  14.787530    127.0.0.1 → 127.0.0.1    TCP 56 61485 → 9515 [ACK]
Seq=46 Ack=37343 Win=370944 Len=0 TSval=1457835671 TSecr=1457835671
  926  60.179214    127.0.0.1 → 127.0.0.1    TCP 44 [TCP Keep-Alive]
9515 → 61485 [ACK] Seq=37342 Ack=46 Win=408192 Len=0
  927  60.179253    127.0.0.1 → 127.0.0.1    TCP 56 [TCP Keep-Alive
ACK] 61485 → 9515 [ACK] Seq=46 Ack=37343 Win=370944 Len=0
TSval=1457880783 TSecr=1457835671
 1605 105.946880    127.0.0.1 → 127.0.0.1    TCP 44 [TCP Keep-Alive]
9515 → 61485 [ACK] Seq=37342 Ack=46 Win=408192 Len=0
 1606 105.946901    127.0.0.1 → 127.0.0.1    TCP 56 [TCP Keep-Alive
ACK] 61485 → 9515 [ACK] Seq=46 Ack=37343 Win=370944 Len=0
TSval=1457926155 TSecr=1457835671
 2275 151.222529    127.0.0.1 → 127.0.0.1    TCP 44 [TCP Keep-Alive]
9515 → 61485 [ACK] Seq=37342 Ack=46 Win=408192 Len=0
 2276 151.222569    127.0.0.1 → 127.0.0.1    TCP 56 [TCP Keep-Alive
ACK] 61485 → 9515 [ACK] Seq=46 Ack=37343 Win=370944 Len=0
TSval=1457971160 TSecr=1457835671

The wireshark packet monitoring result for httpbin.org is the
following. FIN is sent by bash. Does anybody know why FIN is not sent
in the chromedriver case but is sent in the httpbin.org case? Is it
the reason the chromedriver case hangs? How to make it not hang?
Thanks.

    1   0.000000 192.168.1.35 → 54.91.118.50 TCP 78 59682 → 80 [SYN]
Seq=0 Win=65535 Len=0 MSS=1460 WS=64 TSval=1457411580 TSecr=0
SACK_PERM=1
    2   0.047841 54.91.118.50 → 192.168.1.35 TCP 74 80 → 59682 [SYN,
ACK] Seq=0 Ack=1 Win=26847 Len=0 MSS=1460 SACK_PERM=1 TSval=803742967
TSecr=1457411580 WS=256
    3   0.047889 192.168.1.35 → 54.91.118.50 TCP 66 59682 → 80 [ACK]
Seq=1 Ack=1 Win=131712 Len=0 TSval=1457411627 TSecr=803742967
    4   0.048285 192.168.1.35 → 54.91.118.50 TCP 85 GET /get HTTP/1.1
[TCP segment of a reassembled PDU]
    5   0.101234 54.91.118.50 → 192.168.1.35 TCP 66 80 → 59682 [ACK]
Seq=1 Ack=20 Win=26880 Len=0 TSval=803742980 TSecr=1457411627
    6   0.101284 192.168.1.35 → 54.91.118.50 HTTP 106 GET /get HTTP/1.1
    7   0.148444 54.91.118.50 → 192.168.1.35 TCP 66 80 → 59682 [ACK]
Seq=1 Ack=60 Win=26880 Len=0 TSval=803742992 TSecr=1457411680
    8   0.157207 54.91.118.50 → 192.168.1.35 TCP 291 HTTP/1.1 200 OK
[TCP segment of a reassembled PDU]
    9   0.157209 54.91.118.50 → 192.168.1.35 HTTP 265 HTTP/1.1 200 OK
(application/json)
   10   0.157249 192.168.1.35 → 54.91.118.50 TCP 66 59682 → 80 [ACK]
Seq=60 Ack=226 Win=131520 Len=0 TSval=1457411734 TSecr=803742994
   11   0.157272 192.168.1.35 → 54.91.118.50 TCP 66 59682 → 80 [ACK]
Seq=60 Ack=426 Win=131328 Len=0 TSval=1457411734 TSecr=803742994
   12   1.176233 192.168.1.35 → 54.91.118.50 TCP 66 59682 → 80 [FIN,
ACK] Seq=60 Ack=426 Win=131328 Len=0 TSval=1457412744 TSecr=803742994
   13   1.227670 54.91.118.50 → 192.168.1.35 TCP 66 80 → 59682 [ACK]
Seq=426 Ack=61 Win=26880 Len=0 TSval=803743262 TSecr=1457412744

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]