在同一本地网络上从计算机到电话发出POST请求



我正在尝试从我的台式电脑到Unity应用程序与我的手机上的http监听器的post request。

Unity应用监听0.0.0.0:4444。我通过python应用程序使用

向this发送数据
x = requests.post("http://192.168.0.98:4444", data = somestring))

其中192.168.0.98是我手机的ip地址。两台设备连接在同一个网络中。我试过打开USB调试,通过adb和6位配对代码配对设备,通过adb和这里的说明连接设备https://developer.android.com/studio/command-line/adb#wireless.

当我在桌面上运行Unity和python代码时,应用程序可以完美地工作,但是当我在手机上运行它时,我的python代码遇到。

HTTPConnectionPool(host='192.168.0.98', port=4444): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000253FEB996A0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

两分钟后我就解决了这个问题,我只需要把监听器也改成192.168.0.98

最新更新