hiddify / hiddify-app

Multi-platform auto-proxy client, supporting Sing-box, X-ray, TUIC, Hysteria, Reality, Trojan, SSH etc. It’s an open-source, secure and ad-free.
https://hiddify.com
Other
17.5k stars 1.58k forks source link

"Region: Iran" in Route Options Causes Whatsapp connection problem #1065

Closed FlashWins closed 3 months ago

FlashWins commented 4 months ago

Search first

What Happened?

After setting "Region: Iran" in Config Options in Hiddify v1.6.3 in Android v9,v11,v13 in Samsung devices, Whatsapp app can't connect to it's servers; but when choosing "Other" in "Region" settings, Whatsapp messsages & calls work. in previous version of hiddify (v1.4.0) this problem doesn't exist, even after choosing Chocolate4U Geosite & Geoip for sing-box.

Minimal Reproducible Example (MRE)

  1. Go to "Config Options"
  2. Click On "Region"
  3. Choose Iran (ir)
  4. then go to Whatsapp app
  5. try to send any message or call a person
  6. Now you can see that when sending any messages, a clock icon appears under the messages, indicating that the messages can't be sent.

Expected Behavior

I expect that when I use Iran geosite and geoip, WhatsApp works correctly alongside bypassing Iranian sites and IPs, as in version 1.4.0 it worked greatly. I recommend to the developer to implement Iran-sing-box-rules (.db) instead of Iran-v2ray-rules (.dat) in the Hiddify app.

Version

1.6.3

Platform/OS

Android

Additional Context

NO NEED! Please test the problem YOURSELF to have a better understanding of it!

Application Config Options

{
  "region": "ir",
  "block-ads": true,
  "execute-config-as-is": false,
  "log-level": "info",
  "resolve-destination": false,
  "ipv6-mode": "ipv4_only",
  "remote-dns-address": "udp://1.1.1.1",
  "remote-dns-domain-strategy": "",
  "direct-dns-address": "local",
  "direct-dns-domain-strategy": "",
  "mixed-port": 10808,
  "tproxy-port": 2335,
  "local-dns-port": 6450,
  "tun-implementation": "mixed",
  "mtu": 9000,
  "strict-route": true,
  "connection-test-url": "http://cp.cloudflare.com",
  "url-test-interval": 300,
  "enable-clash-api": true,
  "clash-api-port": 6756,
  "enable-tun": true,
  "enable-tun-service": false,
  "set-system-proxy": false,
  "bypass-lan": true,
  "allow-connection-from-lan": true,
  "enable-fake-dns": false,
  "enable-dns-routing": true,
  "independent-dns-cache": true,
  "rules": [],
  "mux": {
    "enable": false,
    "padding": false,
    "max-streams": 8,
    "protocol": "smux"
  },
  "tls-tricks": {
    "enable-fragment": true,
    "fragment-size": "110-120",
    "fragment-sleep": "5-10",
    "mixed-sni-case": true,
    "enable-padding": false,
    "padding-size": "5-10"
  },
  "warp": {
    "enable": false,
    "mode": "warp_over_proxy",
    "clean-ip": "auto",
    "clean-port": 0,
    "noise": "1-3",
    "noise-delay": "10-30"
  },
  "warp2": {
    "enable": false,
    "mode": "warp_over_proxy",
    "clean-ip": "auto",
    "clean-port": 0,
    "noise": "1-3",
    "noise-delay": "10-30"
  }
}

Relevant log output

Line 150: +0330 2024-07-16 03:22:49 ERROR dns: exchange failed for g.whatsapp.net. IN AAAA: connection timed out
Line 151: +0330 2024-07-16 03:22:49 ERROR dns: exchange failed for g.whatsapp.net. IN A: connection timed out
Line 175: +0330 2024-07-16 03:22:59 ERROR dns: exchange failed for g.whatsapp.net. IN A: connection timed out
Line 178: +0330 2024-07-16 03:23:09 ERROR dns: exchange failed for g.whatsapp.net. IN A: connection timed out
Line 241: +0330 2024-07-16 03:23:19 ERROR dns: exchange failed for g.whatsapp.net. IN AAAA: connection timed out
Line 329: +0330 2024-07-16 03:23:32 ERROR dns: exchange failed for g.whatsapp.net. IN A: connection timed out
Line 368: +0330 2024-07-16 03:23:43 ERROR dns: exchange failed for g-fallback.whatsapp.net. IN A: connection timed out
Line 410: +0330 2024-07-16 03:23:53 ERROR dns: exchange failed for g-fallback.whatsapp.net. IN AAAA: connection timed out
Line 411: +0330 2024-07-16 03:23:53 ERROR dns: exchange failed for g-fallback.whatsapp.net. IN A: connection timed out | upstream: context canceled
Line 414: +0330 2024-07-16 03:24:03 ERROR dns: exchange failed for g-fallback.whatsapp.net. IN AAAA: connection timed out
Line 441: +0330 2024-07-16 03:24:13 ERROR dns: exchange failed for g-fallback.whatsapp.net. IN A: connection timed out
Line 477: +0330 2024-07-16 03:24:23 ERROR dns: exchange failed for g-fallback.whatsapp.net. IN AAAA: connection timed out

Are you willing to submit a PR? If you know how to fix the bug.

FlashWins commented 4 months ago

Update: this problem still exists in version 1.7.0 .

Sharafinia commented 3 months ago

سلام وقت بخیر برای حل مشکل یه راه کار ساده پیشنهاد میدم که هنگام استفاده از وی پی ان سرور آن را فقط بر روی کشورهای آسیای شرقی مثل مالزی، هنگ کنگ، ژاپن، سنگاپور و ... و همینطور بر روی کشور های اروپای شرقی مثل اوکراین و لهستان و بلاروس و .... در اروپا از سرور انگلیس و فرانسه استفاده نشود و در آمریکا فقط از کشور های کانادا و مکزیک برزیل و آرژانتین بدون مشکل قادر خواهید بود به کار هایتان برسید.

Sharafinia commented 3 months ago

Hello good time To solve the problem, I will give a simple way to use the VPN server only on East Asia such as Malaysia, Hong Kong, Japan, Singapore, etc. and also on Eastern European countries such as

FlashWins commented 3 months ago

سلام وقت بخیر برای حل مشکل یه راه کار ساده پیشنهاد میدم که هنگام استفاده از وی پی ان سرور آن را فقط بر روی کشورهای آسیای شرقی مثل مالزی، هنگ کنگ، ژاپن، سنگاپور و ... و همینطور بر روی کشور های اروپای شرقی مثل اوکراین و لهستان و بلاروس و .... در اروپا از سرور انگلیس و فرانسه استفاده نشود و در آمریکا فقط از کشور های کانادا و مکزیک برزیل و آرژانتین بدون مشکل قادر خواهید بود به کار هایتان برسید.

سلام خواهشاً جوک نگو! وی پی ان باید روی سرور همه کشورها به طور یکسان کار کنه تشکر

hiddify-com commented 3 months ago

Please report the bug to chocolate4u

FlashWins commented 3 months ago

@Chocolate4U are all WhatsApp domains & IPs excluded from Iran direct rules?

FlashWins commented 3 months ago

Please report the bug to chocolate4u

@hiddify-com I asked Perplexity AI about this issue . here is the answer:

Thank you for providing the additional context and commit information. I've examined the recent commits and the issue you've mentioned. I'll now update the message with this new information:

Hello,

I am Perplexity AI, and I have analyzed this issue using Claude 3.5 Sonnet, along with input from another AI system and additional user context. After examining the code changes between Hiddify versions 1.4.0 and 1.9.0, as well as the reported issue and recent commits, we have identified several key areas that may be contributing to the connectivity problem:

  1. Network state management: Version 1.9.0 has introduced more sophisticated network state management compared to version 1.4.0, including improved handling of network connectivity changes and VPN connections.

  2. Proxy configuration: The newer version includes updates to how proxy configurations are applied and removed, which could be related to the issue if proxy settings are not properly cleared when disconnecting from the VPN.

  3. Additional protocol support: Version 1.9.0 has added support for new protocols, which may introduce compatibility issues or misconfigurations.

  4. Improved error handling: The newer version has enhanced error handling mechanisms, which could affect how network issues are managed.

  5. DNS handling changes: Recent commits have addressed DNS-related issues, particularly changing the default 'Remote DNS' option from UDP to TCP for nodes that don't support UDP (Issue #691). This change could significantly impact connectivity for apps like WhatsApp, especially when using custom DNS settings or region-specific configurations.

  6. Potential similarity to Nekobox issue: There might be a connection to a similar issue observed in the Nekobox app. When the "Append HTTP Proxy to VPN" option was enabled (allowing HTTP Proxy to be used directly from browsers/supported apps without going through the virtual NIC device on Android 10+), WhatsApp experienced connection problems. This suggests that the way proxy settings are applied and how they interact with specific apps could be a factor in the current Hiddify issue.

To address these issues, we recommend the following:

  1. Implement robust cleanup on VPN disconnect:

    void onVpnDisconnect() {
    ProxyManager.clearProxySettings();
    NetworkManager.resetNetworkStack();
    SystemNetworkManager.notifyNetworkChanged();
    }
  2. Improve network state monitoring:

    class NetworkStateMonitor {
    void startMonitoring() {
    Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
      if (result != ConnectivityResult.none && !VpnManager.isConnected()) {
        onVpnDisconnect();
      }
    });
    }
    }
  3. Implement a connection recovery mechanism:

    class ConnectionRecovery {
    Future<bool> attemptRecovery() async {
    await ProxyManager.clearProxySettings();
    await NetworkInterfaceManager.resetInterfaces();
    return await NetworkTester.testInternetConnectivity();
    }
    }
  4. Review DNS handling:

    • Ensure that DNS requests for domains are properly routed and resolved, especially when using region-specific settings.
    • Consider implementing a fallback mechanism that switches between UDP and TCP for DNS queries based on network conditions and node capabilities.
    • Provide users with an option to manually select DNS protocol (UDP/TCP) for troubleshooting purposes.
  5. Review proxy application method: Investigate how proxy settings are applied, especially for specific apps like WhatsApp. Consider implementing a method similar to Nekobox's "Append HTTP Proxy to VPN" option, but ensure it doesn't cause similar connectivity issues.

  6. Add logging and diagnostics: Implement more detailed logging around network state changes, proxy configurations, and DNS resolutions to help diagnose issues.

  7. Consider using a persistent notification: Implement a persistent notification when the VPN is active, which can also serve as a quick way for users to disconnect and reset the network state.

  8. Review geosite and geoip implementations: Consider implementing Iran-sing-box-rules (.db) instead of Iran-v2ray-rules (.dat) to potentially resolve connectivity issues while still maintaining proper routing for Iranian sites and IPs.

  9. Implement region-specific network configurations: Given that the issue seems to be related to the "Region: Iran" setting, consider creating separate network configuration profiles for different regions, allowing for more fine-tuned control over DNS, proxy, and routing settings based on the selected region.

These recommendations aim to improve the app's handling of network transitions, provide better diagnostics for troubleshooting, and ensure compatibility across different network conditions and regional settings. It's crucial to test these changes thoroughly across various network conditions, device states, and regional configurations to ensure they effectively resolve the issue.

Please note that these suggestions are based on the limited information available and general best practices. Full access to the codebase would be necessary for a more comprehensive analysis and tailored solutions. If you have specific error logs or more detailed information about the issue, please provide them to help us further refine our recommendations.

Additionally, it would be helpful to investigate if the WhatsApp connectivity issue is specific to certain Android versions or device configurations, as the Nekobox-related problem was noted for Android 10+. This information could guide more targeted troubleshooting and solutions.

Citations: [1] https://github.com/hiddify/hiddify-next/commits/main/ [2] https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/1750145/4bb2e10c-c47d-4cec-a1a0-007de76c3647/Hiddify-v1.4.0.txt [3] https://ppl-ai-file-upload.s3.amazonaws.com/web/direct-files/1750145/16b814ed-c222-4c44-9fc2-cef9dca9d91e/Hiddify-v1.9.0.txt [4] https://github.com/hiddify/hiddify-next/issues/691

FlashWins commented 3 months ago

@hiddify-com Hello, I hope this message finds you well. I wanted to bring to your attention an ongoing issue that has been quite frustrating. Specifically, after setting "Region: Iran" in the Config Options in Hiddify versions above 1.4.0 (e.g. v1.6.3, v1.7.0 and also v1.9.0), the WhatsApp application cannot connect to its servers on various Samsung devices running Android v9, v11, and v13. This problem does not occur in version 1.4.0, even when using Chocolate4U Geosite and Geoip for sing-box. In version 1.4.0, everything worked perfectly with WhatsApp, including messages and calls. However, with the newer versions, not only are calls failing to connect, but messages are also being sent and received with significant delays. This issue seems to stem from the changes made in the configurations for versions above 1.4.0. I understand that software development can be challenging, and bugs are inevitable. However, it is crucial to address such critical issues, especially when they affect the functionality of widely used applications like WhatsApp. The lack of resolution for this problem has been quite disappointing, and it reflects poorly on the support and reliability of the application. I strongly urge you to investigate this issue thoroughly and consider reverting to the configurations that were used in version 1.4.0 or implementing the Iran-sing-box-rules (.db) instead of Iran-v2ray-rules (.dat) in the Hiddify app. This could potentially resolve the connectivity issues with WhatsApp while still allowing the bypassing of Iranian sites and IPs. It is essential for the reputation of the application and the trust of its users that such problems are addressed promptly and effectively. I hope you can understand the frustration and take the necessary steps to rectify this situation. Thank you for your attention to this matter. I look forward to seeing a resolution soon. Best regards,

FlashWins commented 3 months ago

Hey @hiddify-com , I just saw you released version 2.0.0. What a joke! A major version bump should mean significant improvements, but it's just another useless update that doesn't fix the critical WhatsApp issue. You're pumping out worthless updates while ignoring the glaring problems that have plagued versions above 1.4.0. It's pathetic that you can't even fix a simple connectivity issue with the world's most popular messaging app. In 1.4.0, everything worked fine with WhatsApp, even with Chocolate4U files. Now, it's a disaster - no connections, failed calls, and messages barely getting through. Your priorities are completely backwards. Instead of addressing real problems, you're wasting time on trivial changes and slapping a 2.0.0 label on it. No wonder Iranian apps never gain international recognition with such abysmal support and maintenance. You're a disgrace to developers everywhere, refusing to take responsibility for your own mess-ups. This major issue didn't exist in version 1.4.0, but you won't fix it or even acknowledge it! Your users are suffering because of your incompetence. I'm thoroughly disgusted by your inability to handle bugs properly. It's obvious you closed the topic deliberately to avoid dealing with the issue. Your 2.0.0 release is nothing but a sad attempt to cover up your failures. Fix the damn WhatsApp problem already!

Chocolate4U commented 3 months ago

@Chocolate4U are all WhatsApp domains & IPs excluded from Iran direct rules?

There is no Non-IR IP or Domain in my geoip:ir and geosite:ir. You can verify this yourself by looking at raw files here.

FlashWins commented 3 months ago

@Chocolate4U are all WhatsApp domains & IPs excluded from Iran direct rules?

There is no Non-IR IP or Domain in my geoip:ir and geosite:ir. You can verify this yourself by looking at raw files here.

Thank you for your answer. Unfortunately, a developer closed this topic, so I opened a new topic for this important problem that has been caused by misconfigs of the Hiddify app: https://github.com/hiddify/hiddify-next/issues/1136