1

According to flutter-dev I try to run dart code ( same as shelf-example bin/server.dart ) .

It works on my Android device, because when I run curl -v "http://{my Android device LAN ip}:8080/helloworld", my Android device return Hello, World! quickly.

But when it runs on my iPhone12 (iOS 16.0.2), when I run curl -v "http://{my iOS device LAN ip}:8080/helloworld", curl will raise error below

*   Trying {my iOS device LAN ip}:8080...
* connect to {my iOS device LAN ip} port 8080 failed: Operation timed out
* Failed to connect to {my iOS device LAN ip} port 8080 after 75004 ms: Operation timed out
* Closing connection 0
curl: (28) Failed to connect to {my iOS device LAN ip} port 8080 after 75004 ms: Operation timed out

ping {my iOS device LAN ip} is ok

PING {my iOS device LAN ip} ({my iOS device LAN ip}): 56 data bytes
64 bytes from {my iOS device LAN ip}: icmp_seq=0 ttl=64 time=249.370 ms
64 bytes from {my iOS device LAN ip}: icmp_seq=1 ttl=64 time=171.025 ms
64 bytes from {my iOS device LAN ip}: icmp_seq=2 ttl=64 time=92.354 ms

telnet other port (such as 8081) will suddenly raise error Connection refused, when 8080 will wait a while and raise error Operation timed out.

So I think the dart code part is ok, but some important network config need to set.

So I have tried to add text bellow in Info-Debug.plist and Info-Release.plist but it not works.

    <key>NSLocalNetworkUsageDescription</key>
    <string>Desp</string>
    <key>NSBonjourServices</key>
    <array>
        <string>_dartobservatory._tcp</string>
    </array>

Is there any aspect I haven't considered? Any suggestion is appreciated.

1 Answer 1

2

So I think the dart code part is ok, but some important network config need to set.

After some days search, finally I get the key bug: Local Network Usage Permission.

Following to this answer , I add those code to Info.plist and xxx.swift, and agree the permission request dialog, finally, the http request can send to iPhone-Http-Server.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.