You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
π Bug Report β Closing TCP socket that didn't finish connection takes ~20 seconds, during which it still counts towards max outbound connection limit
#2060
Open
mornveig opened this issue
Apr 26, 2024
· 0 comments
Closing TCP socket that didn't finish connection (for example host is unresponsive or port is closed) takes about ~21 seconds both locally and when deployed as cloudflare worker. During that time TCP socket does count towards outbound connection limit, and there seems to be no way currently to forcibly close the socket.
The following code could be used to check the time it takes to close the socket:
import { connect } from 'cloudflare:sockets';
export default {
async fetch(request, env, ctx) {
var start_time = Date.now();
async function socket_connect_close() {
var socket = connect({ hostname: "8.8.8.8", port: 9999 });
await socket.close();
return Date.now() - start_time;
}
return new Response(JSON.stringify({'close_time': await socket_connect_close()}), {headers: {"Content-Type": "application/json"}});
},
};
If connection limit is reached, properly closing unresponsive connection delays all new connections by 21 seconds which sometimes is undesirable.
It'd be great if there was a way to control connect/close timeout for TCP sockets.
The text was updated successfully, but these errors were encountered:
Hi team,
Closing TCP socket that didn't finish connection (for example host is unresponsive or port is closed) takes about ~21 seconds both locally and when deployed as cloudflare worker. During that time TCP socket does count towards outbound connection limit, and there seems to be no way currently to forcibly close the socket.
The following code could be used to check the time it takes to close the socket:
If connection limit is reached, properly closing unresponsive connection delays all new connections by 21 seconds which sometimes is undesirable.
It'd be great if there was a way to control connect/close timeout for TCP sockets.
The text was updated successfully, but these errors were encountered: