Fffys

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

  •  
  •   Fffys · Dec 27, 2023 · 2416 views
    This topic created in 1059 days ago, the information mentioned may be changed or developed.
    • 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 replies  •  2024-01-31 09:05:24 +08:00
    66Zi2nJk5Z6mdtzj
    66Zi2nJk5Z6mdtzj
    Dec 27, 2023 via iPhone❤️1
    1
    选一个 api ,导出成 curl ,然后加上-v 的参数,debug 看看,是不是连了同一个服务器,然后对比一下两个机器的日志差异先。
    superrichman
    superrichman
    Dec 27, 2023
    2
    你开了代理,他没开代理
    Fffys
    Fffys
    OP
    Jan 31, 2024
    3
    最后,依然不知道问题在哪里,但是换了个网络环境就没有问题了,看来还是网络原因……后来我们做了网速测试,发现我平常的网络环境 gitter 很大但是同学的就很小
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3885 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 09:40 · PVG 17:40 · LAX 01:40 · JFK 04:40
    ♥ Do have faith in what you're doing.