无法从同一 Wi-Fi 网络上的另一台设备连接到本地托管的 Neo4j 服务器



背景

我正在使用Neo4J社区版3.2.0用于托管服务器,以实现移动应用程序。要进行测试,我正在笔记本电脑上运行服务器,在其本地主机上运行Windows 10,以便可以在localhost:81上访问服务器(我最初是使用7474作为端口,但是我会了解为什么我会在第二秒内更改(。我还可以在127.0.0.1:81(这是同一件事(上访问此服务器,并使用我从cmd中运行ipconfig获得的IPv4地址(例如,192.168.1.5(。

问题

我的问题是,我无法从另一台连接到笔记本电脑上的网络的设备访问该服务器(即我的手机(。当我尝试通过url 192.168.1.5:81连接到它时,它就会出来。

尝试解决方案

正如我之前说的,我以前使用7474作为端口号,无济于事。我检查了我的防火墙,端口没有被阻止,只是为了确保我添加了一个入站规则以允许连接到该端口。当这种情况不起作用时,我尝试将端口号切换为5050和80之类的随机数,但仍然没有任何效果。81只是我尝试的最后一个数字。我的防火墙并没有阻止任何neo4j的端口。

我还尝试使用搜索" IP地址"发现的计算机的全局IP地址,但这也不起作用。

我的neo4j.conf文件如下:

#***************************************************************
# Server configuration
#
# For more details and a complete list of settings, please see
# #{settings-reference.url}
#***************************************************************
# This setting constrains all `LOAD CSV` import files to be under the `import` directory. Remove or uncomment it to
# allow files to be loaded from anywhere in filesystem; this introduces possible security problems. See the `LOAD CSV`
# section of the manual for details.
dbms.directories.import=import
# Require (or disable the requirement of) auth to access Neo4j
dbms.security.auth_enabled=true
# With default configuration Neo4j only accepts local connections.
# To accept non-local connections, uncomment this line:
dbms.connectors.default_listen_address=0.0.0.0
# You can also choose a specific network interface, and configure a non-default
# port for each connector, by setting their individual listen_address.
# The address at which this server can be reached by its clients. This may be the server's IP address or DNS name, or
# it may be the address of a reverse proxy which sits in front of the server. This setting may be overridden for
# individual connectors below.
#dbms.connectors.default_advertised_address=localhost
# You can also choose a specific advertised hostname or IP address, and
# configure an advertised port for each connector, by setting their
# individual advertised_address.
# Bolt connector
dbms.connector.bolt.enabled=true
#dbms.connector.bolt.tls_level=OPTIONAL
#dbms.connector.bolt.listen_address=:7687
# HTTP Connector
dbms.connector.http.enabled=true
dbms.connector.http.listen_address=:81
# HTTPS Connector
dbms.connector.https.enabled=true
dbms.connector.https.listen_address=:82
# Certificates directory
# dbms.directories.certificates=certificates
#*****************************************************************
# Administration client configuration
#*****************************************************************

# Comma separated list of JAX-RS packages containing JAX-RS resources, one
# package name for each mountpoint. The listed package names will be loaded
# under the mountpoints specified. Uncomment this line to mount the
# org.neo4j.examples.server.unmanaged.HelloWorldResource.java from
# neo4j-examples under /examples/unmanaged, resulting in a final URL of
# http://localhost:${default.http.port}/examples/unmanaged/helloworld/{nodeId}
#dbms.unmanaged_extension_classes=org.neo4j.examples.server.unmanaged=/examples/unmanaged
#*****************************************************************
# HTTP logging configuration
#*****************************************************************
# HTTP logging is disabled. HTTP logging can be enabled by setting this
# property to 'true'.
dbms.logs.http.enabled=false
# Enable this to be able to upgrade a store from an older version.
dbms.allow_format_migration=true
# The amount of memory to use for mapping the store files, in bytes (or
# kilobytes with the 'k' suffix, megabytes with 'm' and gigabytes with 'g').
# If Neo4j is running on a dedicated server, then it is generally recommended
# to leave about 2-4 gigabytes for the operating system, give the JVM enough
# heap to hold all your transaction state and query context, and then leave the
# rest for the page cache.
# The default page cache memory assumes the machine is dedicated to running
# Neo4j, and is heuristically set to 50% of RAM minus the max Java heap size.
#dbms.memory.pagecache.size=10g
# Enable this to specify a parser other than the default one.
#cypher.default_language_version=2.0
# Keep logical logs, helps debugging but uses more disk space, enabled for
# legacy reasons To limit space needed to store historical logs use values such
# as: "7 days" or "100M size" instead of "true".
#dbms.tx_log.rotation.retention_policy=7 days
# Enable shell server so that remote clients can connect via Neo4j shell.
#dbms.shell.enabled=true
# The network interface IP the shell will listen on (use 0.0.0.0 for all interfaces).
#dbms.shell.host=127.0.0.1
# The port the shell will listen on, default is 1337.
#dbms.shell.port=1337

如您所见,线dbms.connectors.default_listen_address=0.0.0.0dbms.connector.http.listen_address=:81dbms.connector.https.listen_address=:82未注册并将其设置为相应的值。


我对这里的操作完全不知所措,如果我什至无法从另一台计算机连接到服务器,我将无能为力。我有一种奇怪的感觉,我错过了一些显而易见的东西,但我仍然需要帮助。谢谢!


编辑

  • 我已经咨询了多个stackoverflow帖子等等,但是他们中的大多数只是要说上述行或类似行的东西,这就是我已经做过的。

返回默认版本,只是uncomment

dbms.connectors.default_listen_address=0.0.0.0

 dbms.logs.http.enabled=true

重新启动您将在日志文件夹中获得HTTP.LOG文件。尝试从手机连接到http://192.168.1.5:7474

如果日志文件保持空,则请求未到达服务器。如果没有,请检查内容。如果手机上没有显示任何内容,那么问题是在您的服务器或手机上进行网络的问题(谁知道,当您不使用常规端口号时,浏览器会执行HTTPS?(。 ->关闭防火墙并重试

我解决了我的问题,这确实很愚蠢。在我的防火墙中,我允许在私人网络上进行连接,并在公共网络上阻止了它们。由于某种原因,我也不考虑允许公众联系。这样做最终工作了,因为我的家庭网络以某种方式算作公开。

最新更新