![](/img/trans.png)
[英]How to connect to Neo4j server running on Windows machine from Ubuntu machine?
[英]How to access localhost or 127.0.0.1 on a Windows machine from Ubuntu Production Server?
我需要从连接到客户 PC 的生物识别设备中获取一些数据并将其返回到我的生产服务器。 我正在使用 Mantra MFS100 生物识别设备来捕获用户的生物识别数据。 根据 Mantra 的文档,生物识别服务将在 127.0.0.1 中运行。 我能够利用不同的端点并在本地获取所需的数据(使用 pycharm IDE 窗口)但是当从我的生产 Ubuntu 服务器尝试时它不起作用。
生物识别服务将在 11100 - 11120 端口范围内运行。要使用该服务,我需要发现运行该服务的端口。 发现服务的代码:
import requests
for port in xrange(11100, 11122, 1):
response = requests.request('RDSERVICE', 'http://localhost:%s' % str(port), headers=headers, data=data)
if response.status == "READY":
device_port = port
if port == 11121:
print "Fingerprint device is not connected"
如果服务就绪,我可以继续捕获设备数据:
import requests
response = requests.request('CAPTURE', 'http://localhost:%s/rd/capture' % device_port, headers=headers, data=data)
print response.text
这在我尝试从本地 Windows IDE 和端点作为本地主机或 127.0.0.1 时有效,但在我从 Ubuntu 服务器尝试时不起作用。 从 Ubuntu 服务器尝试时,出现以下错误:
HTTPConnectionPool(host='127.0.1.1', port=11100): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f677d12cf10>: Failed to establish a new connection: [Errno 111]连接被拒绝',))
我还尝试将用户的 ip 作为端点传递给无济于事:
import requests
import socket
ip_address = socket.gethostbyname(socket.gethostname())
response = requests.request('CAPTURE', 'http://%s:%s/rd/capture' % (ip_address, device_port), headers=headers, data=data)
如何从 Python 中的 Ubuntu Server(NGINX) 访问 Window 的 Localhost?
编辑:
这是文档中的请求、响应数据: 请求:
RDSERVICE * HTTP/1.1
HOST: http://127.0.0.1:[port]
EXT: APP_NAME
回复:
HTTP/1.1 200 OK
CACHE-CONTROL:no-cache
LOCATION:http://127.0.0.1:<rd_service_port>
Content-Length: length in bytes of the body
Content-Type: text/xml
Connection: Closed
<RDService status="READY|USED|NOTREADY|..." info="provider info for display purposes">
<Interface id="CAPTURE" path="/rd/capture" />
<Interface id="DEVICEINFO" path="/rd/info" />
</RDService>
我通过使用 Javascript 而不是 Python 将逻辑作为 ir.actions.client 操作执行来解决这个问题。当我将逻辑作为客户端操作执行时,我能够访问 Localhost。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.