RMF-WEB 配置网络问题
RMF-WEB 配置网络问题
设置Dashboard的环境(前端)
路径packages/dashboard/.env
其中REACT_APP_TRAJECTORY_SERVER
、REACT_APP_RMF_SERVER
要换成服务器ip地址
# because we are a monorepo, some create-react-app dependencies may be installed in the root directory,
# it complains if it find such packages so we need to disable the check.
SKIP_PREFLIGHT_CHECK=true
REACT_APP_TRAJECTORY_SERVER=ws://localhost:8006
REACT_APP_RMF_SERVER=http://localhost:8000
# REACT_APP_AUTH_PROVIDER="keycloak"
# REACT_APP_KEYCLOAK_CONFIG={"realm":"rmf","clientId":"myclient","url":"http://localhost:8080/"}
(其中注释掉的REACT_APP_AUTH_PROVIDER、REACT_APP_KEYCLOAK_CONFIG是配置登录相关的)
修改结果如下:
设置api-server
路径packages\api-server\api_server\default_config.py
需要将
host
改为0.0.0.0 或 ip 地址,不能使用127.0.0.1或localhostpublic_url
改为http://ip:8000,不能使用http://localhost:8000
# pylint: disable=line-too-long
config = {
# ip or hostname to bind the socket to, this only applies when running the server in
# standalone mode.
# "host": "127.0.0.1", host 不能使用127
# "host":"192.168.3.31", host 可以使用ip
"host": "0.0.0.0", #host 也可以使用0.0.0.0
# port to bind to, this only applies when running the server in standalone mode.
"port": 8000,
"db_url": "sqlite://:memory:",
# url that rmf-server is being served on.
# When being a proxy, this must be the url that rmf-server is mounted on.
# E.g. https://example.com/rmf/api/v1
# "public_url": "http://localhost:8000", 不能使用localhost或127.0.0.1
"public_url": "http://192.168.3.31:8000", #使用ip
"static_directory": "static", # The directory where static files should be stored.
"log_level": "WARNING", # https://docs.python.org/3.8/library/logging.html#levels
# a user that is automatically given admin privileges, note that this does not guarantee that the user exists in the identity provider.
"builtin_admin": "admin",
# path to a PEM encoded RSA public key which is used to verify JWT tokens, if the path is relative, it is based on the working dir.
# "jwt_public_key": "/home/rmf/rmf-web/packages/api-server/api_server/test.pub",
"jwt_public_key": None,
# url to the oidc endpoint, used to authenticate rest requests, it should point to the well known endpoint, e.g.
# http://localhost:8080/auth/realms/rmf-web/.well-known/openid-configuration.
# NOTE: This is ONLY used for documentation purposes, the "jwt_public_key" will be the
# only key used to verify a token.
"oidc_url": "None",
# Audience the access token is meant for. Can also be an array.
# Used to verify the "aud" claim.
"aud": ["rmf_api_server","myclient", "account"],
# url or string that identifies the entity that issued the jwt token
# Used to verify the "iss" claim
# If iss is set to None, it means that authentication should be disabled
# "iss": "http://localhost:8080/realms/rmf",
"iss":None,
# list of arguments passed to the ros node, "--ros-args" is automatically prepended to the list.
# e.g.
# Run with sim time: ["-p", "use_sim_time:=true"]
"ros_args": [],
}
修改结果如下:
打开端口
以下命令分别是查看防火墙状态、开启防火墙、开启端口、防火墙重启
sudo ufw status
sudo ufw enable
sudo ufw allow 8000
sudo ufw allow 3000
sudo ufw allow 8006
sudo ufw reload
其中3000端口对应dashboard前端端口、8000对应api-server、8006对应websocket
在虚拟机上测试时,为了方便直接关闭了防火墙 (不需要)
sudo ufw disable
ubuntu查看端口开放情况
lsof -i:80
telnet 192.168.0.1 80
输入 lsof -i:端口号,若没有信息出现则说明该端口还未开放
也可以通过以下命令,查看所有开放的端口
netstat -aptn
iptables -nL
最终效果
成功在同局域网下的其他设备上访问rmf服务
输入 http://192.168.3.31:3000/ 进行测试
输入 http://192.168.3.31:8000/docs 进行测试
遗留问题
该部署会导致服务器本机3000端口访问8000端口的后端服务时造成跨域问题,可能需要修改前端或后端代码进行修改。
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 刘哥还在学