You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "bryancall (via GitHub)" <gi...@apache.org> on 2026/01/06 23:31:20 UTC
[PR] Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts [trafficserver]
bryancall opened a new pull request, #12786:
URL: https://github.com/apache/trafficserver/pull/12786
Add new SquidLogCode to identify when CONNECT tunnels time out due to active timeout. This makes tunnel timeouts visible in access logs via the crc (cache result code) field.
**Problem:**
Previously, tunnel timeouts were not distinguishable in logs - users could only see them in DEBUG logs.
**Solution:**
- Add `ERR_TUN_ACTIVE_TIMEOUT = 'T'` to SquidLogCode enum
- Set the squid code in `tunnel_handler_ssl_producer()` and `tunnel_handler_ssl_consumer()` on `VC_EVENT_ACTIVE_TIMEOUT`
- Add string mapping in Log.cc
**Result:**
Access logs now show `crc=ERR_TUN_ACTIVE_TIMEOUT` for timed-out CONNECT tunnels.
**Testing:**
Includes autotest `tunnel_active_timeout.test.py` that verifies the squid code is logged correctly.
Addresses [YTSATS-4446](https://ouryahoo.atlassian.net/browse/YTSATS-4446)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on code in PR #12786:
URL: https://github.com/apache/trafficserver/pull/12786#discussion_r2934162671
##########
tests/gold_tests/timeout/tunnel_timeout_client.py:
##########
@@ -0,0 +1,96 @@
+#!/usr/bin/env python3
+'''
+A simple client that establishes a CONNECT tunnel and then holds the connection
+idle to trigger an active timeout.
+'''
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import socket
+import sys
+import time
+
+
Review Comment:
Fixed in 082f414 — removed unused import.
##########
tests/gold_tests/timeout/tunnel_timeout_client.py:
##########
@@ -0,0 +1,95 @@
+#!/usr/bin/env python3
+'''
+A simple client that establishes a CONNECT tunnel and then holds the connection
+idle to trigger an active timeout.
+'''
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import socket
+import sys
+
+
+def main():
+ if len(sys.argv) < 6:
+ print(f"Usage: {sys.argv[0]} proxy_host proxy_port target_host target_port sleep_seconds")
+ sys.exit(1)
+
+ proxy_host = sys.argv[1]
+ proxy_port = int(sys.argv[2])
+ target_host = sys.argv[3]
+ target_port = int(sys.argv[4])
+ sleep_seconds = int(sys.argv[5])
+
+ # Connect to the proxy
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.settimeout(10)
+
+ try:
+ sock.connect((proxy_host, proxy_port))
+ print(f"Connected to proxy {proxy_host}:{proxy_port}")
+
+ # Send CONNECT request
+ connect_request = f"CONNECT {target_host}:{target_port} HTTP/1.1\r\nHost: {target_host}:{target_port}\r\n\r\n"
+ sock.sendall(connect_request.encode())
+ print(f"Sent CONNECT request for {target_host}:{target_port}")
+
+ # Read the response
+ response = b""
+ while b"\r\n\r\n" not in response:
+ data = sock.recv(1024)
+ if not data:
+ break
+ response += data
+
+ response_str = response.decode()
+ print(f"Received response: {response_str.strip()}")
+
+ if "200" not in response_str:
+ print(f"CONNECT failed: {response_str}")
+ sock.close()
+ sys.exit(1)
+
+ print(f"Tunnel established, sleeping for {sleep_seconds} seconds to trigger active timeout...")
+
+ # Now hold the connection idle until the active timeout fires
+ # Use a longer socket timeout so we can detect when ATS closes the connection
+ sock.settimeout(sleep_seconds + 5)
+
+ try:
+ # Wait for data or connection close
+ data = sock.recv(1024)
+ if not data:
+ print("Connection closed by server (timeout)")
+ else:
+ print(f"Received data: {data}")
+ except socket.timeout:
+ print("Socket timeout waiting for server")
+ except Exception as e:
+ print(f"Exception: {e}")
+
+ except socket.timeout:
+ print("Socket timeout during connect/handshake")
+ except Exception as e:
+ print(f"Error: {e}")
+ finally:
+ sock.close()
+
Review Comment:
Fixed in 082f414 — switched to context manager.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on PR #12786:
URL: https://github.com/apache/trafficserver/pull/12786#issuecomment-4254741280
Cherry-picked to 10.2.x
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts [trafficserver]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12786:
URL: https://github.com/apache/trafficserver/pull/12786#discussion_r2666605936
##########
tests/gold_tests/timeout/tunnel_timeout_client.py:
##########
@@ -0,0 +1,96 @@
+#!/usr/bin/env python3
+'''
+A simple client that establishes a CONNECT tunnel and then holds the connection
+idle to trigger an active timeout.
+'''
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import socket
+import sys
+import time
+
+
Review Comment:
Import of 'time' is not used.
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall merged PR #12786:
URL: https://github.com/apache/trafficserver/pull/12786
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts [trafficserver]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #12786:
URL: https://github.com/apache/trafficserver/pull/12786#discussion_r2676502776
##########
tests/gold_tests/timeout/tunnel_timeout_client.py:
##########
@@ -0,0 +1,95 @@
+#!/usr/bin/env python3
+'''
+A simple client that establishes a CONNECT tunnel and then holds the connection
+idle to trigger an active timeout.
+'''
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import socket
+import sys
+
+
+def main():
+ if len(sys.argv) < 6:
+ print(f"Usage: {sys.argv[0]} proxy_host proxy_port target_host target_port sleep_seconds")
+ sys.exit(1)
+
+ proxy_host = sys.argv[1]
+ proxy_port = int(sys.argv[2])
+ target_host = sys.argv[3]
+ target_port = int(sys.argv[4])
+ sleep_seconds = int(sys.argv[5])
+
+ # Connect to the proxy
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.settimeout(10)
+
+ try:
+ sock.connect((proxy_host, proxy_port))
+ print(f"Connected to proxy {proxy_host}:{proxy_port}")
+
+ # Send CONNECT request
+ connect_request = f"CONNECT {target_host}:{target_port} HTTP/1.1\r\nHost: {target_host}:{target_port}\r\n\r\n"
+ sock.sendall(connect_request.encode())
+ print(f"Sent CONNECT request for {target_host}:{target_port}")
+
+ # Read the response
+ response = b""
+ while b"\r\n\r\n" not in response:
+ data = sock.recv(1024)
+ if not data:
+ break
+ response += data
+
+ response_str = response.decode()
+ print(f"Received response: {response_str.strip()}")
+
+ if "200" not in response_str:
+ print(f"CONNECT failed: {response_str}")
+ sock.close()
+ sys.exit(1)
+
+ print(f"Tunnel established, sleeping for {sleep_seconds} seconds to trigger active timeout...")
+
+ # Now hold the connection idle until the active timeout fires
+ # Use a longer socket timeout so we can detect when ATS closes the connection
+ sock.settimeout(sleep_seconds + 5)
+
+ try:
+ # Wait for data or connection close
+ data = sock.recv(1024)
+ if not data:
+ print("Connection closed by server (timeout)")
+ else:
+ print(f"Received data: {data}")
+ except socket.timeout:
+ print("Socket timeout waiting for server")
+ except Exception as e:
+ print(f"Exception: {e}")
+
+ except socket.timeout:
+ print("Socket timeout during connect/handshake")
+ except Exception as e:
+ print(f"Error: {e}")
+ finally:
+ sock.close()
+
Review Comment:
Instance of context-manager class [socket](1) is closed in a finally block. Consider using 'with' statement.
```suggestion
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.settimeout(10)
try:
sock.connect((proxy_host, proxy_port))
print(f"Connected to proxy {proxy_host}:{proxy_port}")
# Send CONNECT request
connect_request = f"CONNECT {target_host}:{target_port} HTTP/1.1\r\nHost: {target_host}:{target_port}\r\n\r\n"
sock.sendall(connect_request.encode())
print(f"Sent CONNECT request for {target_host}:{target_port}")
# Read the response
response = b""
while b"\r\n\r\n" not in response:
data = sock.recv(1024)
if not data:
break
response += data
response_str = response.decode()
print(f"Received response: {response_str.strip()}")
if "200" not in response_str:
print(f"CONNECT failed: {response_str}")
sys.exit(1)
print(f"Tunnel established, sleeping for {sleep_seconds} seconds to trigger active timeout...")
# Now hold the connection idle until the active timeout fires
# Use a longer socket timeout so we can detect when ATS closes the connection
sock.settimeout(sleep_seconds + 5)
try:
# Wait for data or connection close
data = sock.recv(1024)
if not data:
print("Connection closed by server (timeout)")
else:
print(f"Received data: {data}")
except socket.timeout:
print("Socket timeout waiting for server")
except Exception as e:
print(f"Exception: {e}")
except socket.timeout:
print("Socket timeout during connect/handshake")
except Exception as e:
print(f"Error: {e}")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on PR #12786:
URL: https://github.com/apache/trafficserver/pull/12786#issuecomment-4068676129
[approve ci autest 0 autest 1 rocky]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add ERR_TUN_ACTIVE_TIMEOUT squid code for tunnel timeouts [trafficserver]
Posted by "bryancall (via GitHub)" <gi...@apache.org>.
bryancall commented on PR #12786:
URL: https://github.com/apache/trafficserver/pull/12786#issuecomment-3740900211
@bryancall make sure this change doesn't brake traffic_logstats
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org