51d5e2f822a1f5333d2b4c91a0eff20980900768
jcasper
  Thu Jan 22 17:13:45 2026 -0800
botDelay needs to explain that it failed to connect to the bottleneck server
so that we know what to fix when it happens, refs #36992

diff --git src/hg/lib/botDelay.c src/hg/lib/botDelay.c
index 5d005945ef6..5aba264b577 100644
--- src/hg/lib/botDelay.c
+++ src/hg/lib/botDelay.c
@@ -11,35 +11,56 @@
 #include "hgConfig.h"
 #include "cheapcgi.h"
 #include "hui.h"
 #include "hCommon.h"
 #include "botDelay.h"
 #include "jsonWrite.h"
 #include "regexHelper.h"
 #include "hubSpaceKeys.h"
 
 #define defaultDelayFrac 1.0   /* standard penalty for most CGIs */
 #define defaultWarnMs 10000    /* warning at 10 to 20 second delay */
 #define defaultExitMs 20000    /* error 429 Too Many Requests after 20+ second delay */
 
 int botDelayWarnMs  = 0;       /* global so the previously used value can be retrieved */
 
+void abortAndExplainConnectFail()
+/* Write out a short 500 response explaining that the connection to the
+ * bottleneck server couldn't be established. Then exit. */
+{
+puts("Content-Type:text/html");
+printf("Status: 500 Interal Server Error\n");
+puts("\n");	/* blank line between header and body */
+
+puts("<!DOCTYPE HTML 4.01 Transitional>\n");
+puts("<html lang='en'>");
+puts("<head>");
+puts("<meta charset=\"utf-8\">");
+printf("<title>Status 500: Internal Server Error</title></head>\n");
+printf("<body><h1>Status 500: Internal Server Error</h1><p>\n");
+printf("Failed to connect to bottleneck server\n</p>");
+puts("</body></html>");
+exit(0);
+}
+
 int botDelayTime(char *host, int port, char *botCheckString)
 /* Figure out suggested delay time for ip address in
  * milliseconds. */
 {
-int sd = netMustConnect(host, port);
+int sd = netConnect(host, port);
+if (sd < 0)
+    abortAndExplainConnectFail();
 char buf[256];
 netSendString(sd, botCheckString);
 netRecieveString(sd, buf);
 close(sd);
 return atoi(buf);
 }
 
 char *botDelayWarningMsg(char *ip, int millis)
 /* return the string for the default botDelay message
  * not all users of botDelay want the message to go to stderr
  * return it for their own use case
  */
 {
 time_t now = time(NULL);
 char *delayMsg = needMem(2048);