TCP\IP client - EHOSTUNREACH (No route to host)

前端 未结 6 609
情歌与酒
情歌与酒 2020-11-28 14:19

I am trying to develop a client server TCP/IP application. I have a server running on my PC and the client app is running on the mobile. They both are in the same Wi-Fi netw

相关标签:
6条回答
  • 2020-11-28 14:49

    download a ping app on your phone and try to ping the server ip if it is ok ... if using apache put the local machine IP in the httpd.conf configuration file.

    # Change this to Listen on specific IP addresses as shown below to 
    # prevent Apache from glomming onto all bound IP addresses.
    #
    #Listen 12.34.56.78:80
    Listen 127.0.0.1:80
    Listen 192.168.1.30:80  (your IP)
    
    0 讨论(0)
  • 2020-11-28 14:51

    I face the same problem when I developed an android application communicate with java desktop server, to solve the problem just disconnect the usb cable that connect the android phone with the PC.

    0 讨论(0)
  • 2020-11-28 14:58

    Hello I had the same problem in my mac and running the app in android device. I had to do following 2 things to make it work:

    1. Switch firewall off in the mac
    2. Enable the infrared receiver (System Pref > Security > Firewall > Advanced)

    And it worked!

    0 讨论(0)
  • 2020-11-28 15:04

    This looks like a networking problem not a Java problem. Either:

    • the networking on the client either doesn't know how to route packets to the server,
    • the client's connection attempt on port 4449 is being blocked by a firewall or packet filter, or
    • you are using the wrong IP address.

    (The "No route to host" message suggests that it is the first problem, but firewalls are sometimes configured to give misleading responses to traffic that is unwanted.)

    Anyway, you would be better off looking for a site on how to configure and / or networks and routing.

    0 讨论(0)
  • 2020-11-28 15:09

    Yep..

    The host is unreachable, just like that. However, if everything is oK (well configured node/network, good wifi signal,..) You can force the process using ping serverIP (from phone) or ping smartphone (from server).

    The ping (ICMP packets) will force the router to speedup the new routing (way to reach the host)... send lot of pings (-n option) eg: ping google.com -n 1000 (1000 consecutive pings)

    0 讨论(0)
  • 2020-11-28 15:12

    The no route error indicates that when the TCP connection was attempted, the connection failed because the underlying protocol software could not find a network node to network node route to the designated target node.

    The fix is somewhat operating system dependent but it mainly requires you to set up your routing tables so that the device from which you are trying to connect is able to figure out how to reach the device to which you want to connect.

    Normally you specify a gateway to which when you attempt to connect, the connection request goes out the network gateway to be resolved by other information technology devices such as routers, etc.

    This looks to be an Android device, so the first thing is to make sure that you have connectivity whether WiFi or cell. Another would be to make sure that the WiFi or cell is turned on and operational.

    The IP address you specify is normally within a private sub-net. So thing to check is is whether the device that you are trying to connect to is on the same sub-net that your device is on.

    Here is a document on sub-nets and routing.

    Quote from comment on Android by user destenson

    A comment from user destenson on May-13-2017 adds this additional information specific to Android and the error messages provided in the posting.

    Since this is android the first thing you need to look at is permissions. 09-21 01:08:40.457: W/System.err(8536): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85) indicates that the connection was denied by policy on the device.

    0 讨论(0)
提交回复
热议问题