Android: Volley NoConnectionError

前端 未结 4 1148
不知归路
不知归路 2021-01-06 06:48

I\'m trying to connect to a REST-Server (which I created with Spark) via Android. I can send POST-Requests with POSTMAN (Chrome Addon) and get what I want, but when I try to

4条回答
  •  孤街浪徒
    2021-01-06 07:04

    127.0.0.1 is the loopback ip address on your android device. You need the ip address of your computer. I presume you 're running on an emulator or Android device of some sort. If your server is running on a local Wifi network, use the IP address of your Wifi adapter then replace 127.0.0.1 with that address.

    TLDR; Use you server's IP address instead of 127.0.0.1

    Linux: ifconfig [wlan0]

    Windows: ipconfig

    Edit 2020:

    On newer versions on Android, all HTTP traffic must be encrypted, otherwise the android framework will throw an error. Therefore it's advisable to use a tunnelling server like Ngrok - which comes with free SSL - when testing on your local server.

提交回复
热议问题