V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Fffys
V2EX  ›  前端开发

为什么我和同学在 postman 使用同样的 API 测试却有不同的结果?

  •  
  •   Fffys · 126 天前 · 1181 次点击
    这是一个创建于 126 天前的主题,其中的信息可能已经有所发展或是发生改变。
    • express 搭建后端,API 测试各种 HTTP 方法都包含了,我们没有同时测试,但是同学所有的 API 调用都返回了 200 我却有一部分得到 409 有一部分 504 还有一个 401 未授权,以及同学完成所有测试只用了 22s 我却用了 4 分钟,有人可以解释一下原因吗?我们都完全不知道要怎么 debug……
    • 同学猜测可能是我网慢,但是网慢会造成每次都是同样的 API 出问题吗?出问题的 API 有的只涉及一个数据的修改而已……

    504 的错误(都是 timeout ):

    Status code | AssertionError: expected response to have status reason 'OK' but got 'CONNECTION TIMED OUT'
    JSON response | AssertionError: expected response body to be a valid json but got error Unexpected token '<' at 1:1
    Body Values | JSONError: Unexpected token '<' at 1:1 <HEAD><TITLE>Connection Timed Out</TITLE></HEAD> ^
    Subscription Field | JSONError: Unexpected token '<' at 1:1 <HEAD><TITLE>Connection Timed Out</TITLE></HEAD> ^
    Account type Field | JSONError: Unexpected token '<' at 1:1 <HEAD><TITLE>Connection Timed Out</TITLE></HEAD> ^
    

    409 的错误:

    Status code | AssertionError: expected response to have status reason 'OK' but got 'CONNECTION TIMED OUT'
    JSON response | AssertionError: expected response body to be a valid json but got error Unexpected token '<' at 1:1
    Body Values | JSONError: Unexpected token '<' at 1:1 <HEAD><TITLE>Connection Timed Out</TITLE></HEAD> ^
    Subscription Field | JSONError: Unexpected token '<' at 1:1 <HEAD><TITLE>Connection Timed Out</TITLE></HEAD> ^
    Account type Field | JSONError: Unexpected token '<' at 1:1 <HEAD><TITLE>Connection Timed Out</TITLE></HEAD> ^
    

    我的环境:

    • mac M1 Monterey
    • mongodb 6.0.11
    • node v18.18.2

    同学的环境:

    • Ubuntu 20
    • mongodb 6.0.3
    • node v18.18.1

    第一次发帖,如果需要提供更多内容会截图的,拜托了!

    3 条回复    2024-01-31 09:05:24 +08:00
    yuanmomo
        1
    yuanmomo  
       126 天前 via iPhone   ❤️ 1
    选一个 api ,导出成 curl ,然后加上-v 的参数,debug 看看,是不是连了同一个服务器,然后对比一下两个机器的日志差异先。
    superrichman
        2
    superrichman  
       126 天前
    你开了代理,他没开代理
    Fffys
        3
    Fffys  
    OP
       91 天前
    最后,依然不知道问题在哪里,但是换了个网络环境就没有问题了,看来还是网络原因……后来我们做了网速测试,发现我平常的网络环境 gitter 很大但是同学的就很小
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2229 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 08:04 · PVG 16:04 · LAX 01:04 · JFK 04:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.