背景
我正在使用Neo4j Community Edition 3.2.0来托管服务器以用于移动应用程序。为了进行测试,我在我的笔记本电脑上运行服务器,在其本地主机上运行Windows 10,以便我可以在localhost:81
访问服务器(我最初使用7474作为端口,但我会明白为什么我改变了一秒钟。我也可以通过127.0.0.1:81
访问此服务器(这是相同的事情)并使用我在ipconfig
中运行cmd
获得的IPv4地址(例如,192.168.1.5
)。
问题
我的问题是,我无法从连接到我的笔记本电脑所在的同一网络的其他设备(即我的手机)访问此服务器。当我尝试通过网址192.168.1.5:81
连接到它时,它只会超时。
尝试解决方案
正如我之前所说,我之前使用7474作为端口号无济于事。我检查了我的防火墙并且端口没有被阻止,只是为了确保我添加了一个入站规则以允许连接到该端口。当这不起作用时,我尝试将端口号切换为5050和80之类的随机数,但仍然无效。 81是我试过的最后一个数字。我的防火墙没有阻止Neo4j的任何端口。
我也尝试使用Googling“ip address”找到的计算机的全局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.0
,dbms.connector.http.listen_address=:81
和dbms.connector.https.listen_address=:82
已取消注释,并设置为相应的值。
我完全不知道该怎么做,如果我甚至无法从另一台机器连接到服务器,我什么也做不了。我有一种奇怪的感觉,我错过了一些可笑的东西,但我仍然需要帮助。谢谢!
EDITS
答案 0 :(得分:1)
返回默认版本并取消注释
dbms.connectors.default_listen_address=0.0.0.0
和
dbms.logs.http.enabled=true
重新启动 您将在logs文件夹中获得一个http.log文件。 尝试从手机连接到http://192.168.1.5:7474
如果日志文件保持为空,则请求不会到达服务器。 如果没有,请检查内容。 如果手机上没有显示任何内容,那么问题就在于您的服务器或手机网络(谁知道,当您不使用通常的端口号时,浏览器会强制执行https?)。 - >关闭防火墙并重试
答案 1 :(得分:0)
我解决了我的问题,这确实是愚蠢的。在我的防火墙中,我允许在专用网络上连接并在公共网络上阻止它们;出于某种原因,我也没想过允许公共连接。这样做最终会起作用,因为我的家庭网络在某种程度上被视为公共。