python - 无法访问Locust WebInterface "ERR_CONNECTION_REFUSED"

标签 python windows locust

我想在 Windows 10 上使用 Locust 测试我的项目。

脚本似乎运行正常(CMD 中没有错误),但我无法连接到 Web 界面 http://127.0.0.1:8089 (ERR_CONNECTION_REFUSED)。

我猜测,这与浏览器/Windows 配置有关,但我找不到问题所在。我在 LAN 设置中没有设置代理,我从 DNS 获取 IP,并且主机文件中没有任何更改。

locustfile.py:

python
from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):
    def on_start(self):
        """ on_start is called when a Locust start before any task is scheduled """
        self.login()

    def on_stop(self):
        """ on_stop is called when the TaskSet is stopping """
        self.logout()

    def login(self):
        self.client.post("/login", {"username":"tester", "password":"abcd1234"})

    def logout(self):
        self.client.post("/logout", {"username":"ellen_key", "password":"education"})

    @task(2)
    def index(self):
        self.client.get("/")

    @task(1)
    def profile(self):
        self.client.get("/profile")

class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 5000
    max_wait = 9000
    host="http://google.com"

CMD:

D:\workspace\WebTesting>locust

CMD 结果:

[2019-05-13 09:49:45,069] LB6-001-DTMH/INFO/locust.main: Starting web monitor at *:8089
[2019-05-13 09:49:45,070] LB6-001-DTMH/INFO/locust.main: Starting Locust 0.11.0

当我在命令行中中断脚本时,我收到 KeyboardInterrupt 消息和一些没有数据的统计信息。

python -m http.server 8089 似乎可以工作。

最佳答案

尝试访问http://localhost:8089/

我不太清楚为什么,但我无法通过 http://127.0.0.1 访问 Locust 网络界面要么(其他网络服务器使用此地址在本地运行良好),但转到本地主机对我来说确实有效。

关于python - 无法访问Locust WebInterface "ERR_CONNECTION_REFUSED",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56108650/

相关文章:

Windows - 开机时自动启动特定应用程序

java - 在 Java 运行时修改内联常量

python - Locustio(Python)登录

python - Pickle 不适用于 tkinter

python - 在python 3中制作 'byte type object'

python - Django 平面页面 : sort list

c++ - 通过索引获取文件名

python - 让 IPython 导入我的意思

python - 从 Locust 获取单个任务的统计信息

python - 安装 locust.io 错误(失败,退出状态 2)