Created
September 25, 2025 04:57
-
-
Save minrk/4ba2f63676cc1bdf646d9dedd504a2b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| services: | |
| proxy: | |
| image: ghcr.io/minrk/configurable-http-proxy:custom-dump-netstat | |
| # build: | |
| # context: .. | |
| command: | |
| - --error-target=http://error-target | |
| - --default-target=http://169.254.0.0 | |
| - --log-level=debug | |
| environment: | |
| DEBUG: "*" | |
| NETSTAT_SECONDS: "10" | |
| ports: | |
| - 8000:8000 | |
| error-target: | |
| image: nginx | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <title>Websocket test</title> | |
| <body> | |
| <input type="checkbox" checked name="pause" id="pause"> | |
| <label for="pause">Pause</label> | |
| <input type="checkbox" checked name="websocket" id="websocket"> | |
| <label for="websocket">WebSocket</label> | |
| <ul id="output"></ul> | |
| <script type="text/javascript"> | |
| // document.location.href; | |
| const htmlUrl = "http://127.0.1:8000/"; | |
| const wsUrl = "ws" + htmlUrl.slice(4); | |
| const connectEveryMs = 100; | |
| function log(msg) { | |
| const ul = document.getElementById("output"); | |
| const li = document.createElement("li"); | |
| li.innerText = `${(new Date()).toLocaleTimeString()} ${msg}`; | |
| ul.insertBefore(li, ul.firstChild); | |
| // limit length | |
| if (ul.childElementCount > 10) { | |
| ul.removeChild(ul.lastChild); | |
| } | |
| } | |
| function connect() { | |
| if (document.getElementById("pause").checked) { | |
| setTimeout(connect, connectEveryMs); | |
| return; | |
| } | |
| if (document.getElementById("websocket").checked) { | |
| connectWs(); | |
| } else { | |
| connectFetch(); | |
| } | |
| }; | |
| async function connectFetch() { | |
| log(`fetching ${htmlUrl}`) | |
| try { | |
| const r = await fetch(htmlUrl); | |
| log("fetched ok"); | |
| } catch (e) { | |
| log(`fetch error ${e.toString()}`); | |
| console.error(e); | |
| } | |
| setTimeout(connect, connectEveryMs); | |
| } | |
| function connectWs() { | |
| log("connecting websocket"); | |
| const ws = new WebSocket(wsUrl); | |
| // connect every this often | |
| // these are all going to fail, | |
| // but it appears that failed ws connections are causing port exhaustion errors | |
| ws.onerror = (err) => { | |
| log("error"); | |
| console.error(err); | |
| }; | |
| ws.onclose = () => { | |
| log("close"); | |
| setTimeout(connect, connectEveryMs); | |
| } | |
| } | |
| connect(); | |
| </script> | |
| </body> | |
| </html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment