You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter应用通过Tailscale调用树莓派本地API无响应的问题求助

Flutter应用通过Tailscale调用树莓派本地API无响应的问题求助

各位大佬好,我最近碰到一个有点棘手的问题,想请教下大家:

我手头的树莓派和安卓手机都装了Tailscale,两台设备互相ping是通的,说明Tailscale的网络连接没问题。树莓派上部署了一个API服务,其中有个测试接口是这样的:

@Get('/test') 
testAPI() { 
  console.log('it works'); 
  return 'it works'; 
}

现在的问题是:

  • 用手机浏览器访问 http://x.x.x.x:3000/auth/test(x.x.x.x是树莓派的Tailscale内网IP),后端控制台能正常打印it works,浏览器也能收到返回的字符串,完全正常;
  • 但用我自己开发的Flutter app发起同样的请求,后端控制台完全没有任何日志输出,app这边也收不到任何响应,就像请求根本没发出去一样。

我已经检查了AndroidManifest.xml的配置,相关权限和明文流量都开了,代码如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:label="vault_app"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:taskAffinity=""
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>

    <queries>
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT"/>
            <data android:mimeType="text/plain"/>
        </intent>
    </queries>
</manifest>

我自己也排查了几个点:

  • 确认Tailscale在手机后台是正常运行的,没有被系统杀死;
  • 手机和树莓派的Tailscale节点状态都是在线的,ping测试一直正常;
  • 已经允许了app的网络权限,系统设置里能看到权限是开启的。

有没有大佬遇到过类似的情况?会不会是Flutter的网络请求代码有什么坑?或者Android针对Tailscale这类VPN网络有什么特殊限制?麻烦指点一下,谢谢大家!

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 11:22:57