Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ntfy sub not working with servers behind cloudflare. #1251

Open
tpkowastaken opened this issue Jan 5, 2025 · 0 comments
Open

Ntfy sub not working with servers behind cloudflare. #1251

tpkowastaken opened this issue Jan 5, 2025 · 0 comments
Labels
🪲 bug Something isn't working

Comments

@tpkowastaken
Copy link

tpkowastaken commented Jan 5, 2025

🐞 Describe the bug

Whenever running ntfy sub https://my-own-ntfy-server.com/TOPIC the command stays idle and doesn't listen to any messages coming to this topic when the servers are routed through cloudflare tunnels. It gives a 524 after a while.

tom@toms-MacBook-Pro ~ % ntfy sub https://my-own-ntfy-server.com/JIDLO
2025/01/06 01:12:27 WARN my-own-ntfy-server.com/JIDLO Connection failed: error code: 524

💻 Components impacted

  • ntfy cli

💡 Screenshots and/or logs

curl to the server
tom@toms-MacBook-Pro ~ % curl https://my-own-ntfy-server.com/JIDLO
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>ntfy web</title>

    <!-- Mobile view -->
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="HandheldFriendly" content="true" />

    <!-- Mobile browsers, background color -->
    <meta name="theme-color" content="#317f6f" />
    <meta name="msapplication-navbutton-color" content="#317f6f" />
    <meta name="apple-mobile-web-app-status-bar-style" content="#317f6f" />
    <link rel="apple-touch-icon" href="/static/images/apple-touch-icon.png" sizes="180x180" />
    <link rel="mask-icon" href="/static/images/mask-icon.svg" color="#317f6f" />

    <!-- Favicon, see favicon.io -->
    <link rel="icon" type="image/png" href="/static/images/favicon.ico" />

    <!-- Previews in Google, Slack, WhatsApp, etc. -->
    <meta
      name="description"
      content="ntfy lets you send push notifications via scripts from any computer or phone. Made with ❤ by Philipp C. Heckel, Apache License 2.0, source at https://heckel.io/ntfy."
    />
    <meta property="og:type" content="website" />
    <meta property="og:locale" content="en_US" />
    <meta property="og:site_name" content="ntfy web" />
    <meta property="og:title" content="ntfy web" />
    <meta
      property="og:description"
      content="ntfy lets you send push notifications via scripts from any computer or phone. Made with ❤ by Philipp C. Heckel, Apache License 2.0, source at https://heckel.io/ntfy."
    />
    <meta property="og:image" content="/static/images/ntfy.png" />
    <meta property="og:url" content="https://ntfy.sh" />

    <!-- Never index -->
    <meta name="robots" content="noindex, nofollow" />

    <!-- Style overrides & fonts -->
    <link rel="stylesheet" href="/static/css/app.css" type="text/css" />
    <link rel="stylesheet" href="/static/css/fonts.css" type="text/css" />

    <!-- PWA -->
    <link rel="manifest" href="/manifest.webmanifest" />
    <script type="module" crossorigin src="/static/media/index-9e24212a.js"></script>
  </head>
  <body>
    <noscript>
      ntfy web requires JavaScript, but you can also use the
      <a href="https://ntfy.sh/docs/subscribe/cli/">CLI</a> or <a href="https://ntfy.sh/docs/subscribe/phone/">Android/iOS app</a> to
      subscribe.
    </noscript>
    <div id="root"></div>
    <script src="/config.js"></script>

  </body>
</html>
listening to websockets using wscat
wscat -c "wss://my-own-ntfy-server.com/JIDLO/ws"
Connected (press CTRL+C to quit)
< {"id":"8vkXwNdH0FS7","time":1736148218,"event":"open","topic":"JIDLO"}

< {"id":"SJpq3axiPrJv","time":1736148221,"expires":1736191421,"event":"message","topic":"JIDLO","message":"JIDLO","priority":3}

🔮 Additional context

The server that is hosting ntfy is behind cloudflare tunnels because of my limited network. Cloudflare tunnels enforce using https therefore using http is not an option. Cloudflare supports wss as shown

Also the server and command is completely fine when connecting through my local network:

ntfy sub http://192.168.100.128/JIDLO
{"id":"IxsiF9K1CguP","time":1736120908,"expires":1736164108,"event":"message","topic":"JIDLO","message":"JIDLO","priority":3}

Curl looks the same on both

curl to the local server

curl http://192.168.100.128/JIDLO
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>ntfy web</title>

    <!-- Mobile view -->
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="HandheldFriendly" content="true" />

    <!-- Mobile browsers, background color -->
    <meta name="theme-color" content="#317f6f" />
    <meta name="msapplication-navbutton-color" content="#317f6f" />
    <meta name="apple-mobile-web-app-status-bar-style" content="#317f6f" />
    <link rel="apple-touch-icon" href="/static/images/apple-touch-icon.png" sizes="180x180" />
    <link rel="mask-icon" href="/static/images/mask-icon.svg" color="#317f6f" />

    <!-- Favicon, see favicon.io -->
    <link rel="icon" type="image/png" href="/static/images/favicon.ico" />

    <!-- Previews in Google, Slack, WhatsApp, etc. -->
    <meta
      name="description"
      content="ntfy lets you send push notifications via scripts from any computer or phone. Made with ❤ by Philipp C. Heckel, Apache License 2.0, source at https://heckel.io/ntfy."
    />
    <meta property="og:type" content="website" />
    <meta property="og:locale" content="en_US" />
    <meta property="og:site_name" content="ntfy web" />
    <meta property="og:title" content="ntfy web" />
    <meta
      property="og:description"
      content="ntfy lets you send push notifications via scripts from any computer or phone. Made with ❤ by Philipp C. Heckel, Apache License 2.0, source at https://heckel.io/ntfy."
    />
    <meta property="og:image" content="/static/images/ntfy.png" />
    <meta property="og:url" content="https://ntfy.sh" />

    <!-- Never index -->
    <meta name="robots" content="noindex, nofollow" />

    <!-- Style overrides & fonts -->
    <link rel="stylesheet" href="/static/css/app.css" type="text/css" />
    <link rel="stylesheet" href="/static/css/fonts.css" type="text/css" />

    <!-- PWA -->
    <link rel="manifest" href="/manifest.webmanifest" />
    <script type="module" crossorigin src="/static/media/index-9e24212a.js"></script>
  </head>
  <body>
    <noscript>
      ntfy web requires JavaScript, but you can also use the
      <a href="https://ntfy.sh/docs/subscribe/cli/">CLI</a> or <a href="https://ntfy.sh/docs/subscribe/phone/">Android/iOS app</a> to
      subscribe.
    </noscript>
    <div id="root"></div>
    <script src="/config.js"></script>

  </body>
</html>

@tpkowastaken tpkowastaken added the 🪲 bug Something isn't working label Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant