问答 使用 Gatling 进行性能测试,报错 (Address already in use: no further information)

arrow · 2018年09月27日 · 最后由 arrow 回复于 2018年10月10日 · 2434 次阅读

测试环境

  • Win 7 x64
  • Java 1.8.0
  • Gatling 3.0.0-RC2

测试脚本

class MySimulation extends Simulation {
  val httpConf = http
    .baseUrl("http://192.168.1.244:1099")
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
    .acceptEncodingHeader("gzip, deflate")
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")

  val scn = scenario("Scenario Name")
    .exec(http("request_1").get("/index.html"))

  setUp(
    scn.inject(
      constantUsersPerSec(500) during(10 minutes)  // 500个并发运行10分钟
    ).protocols(httpConf)
  )
}

错误信息

Wrapped by: io.netty.channel.AbstractChannel$AnnotatedSocketException: Address already in use: no further information: /192.168.1.244:1099
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
        at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
        at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327)
        at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:616)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Thread.java:748)

google 到解决方案是端口不够链接,使用下面的命令增加端口配置

netsh int ipv4 set dynamic tcp start=1025 num=57975

但是修改了后,仍出现相同的错误,使用 netsh -an 查看端口使用情况,居然占用了 20000 多个端口。。。

是我哪里配置不对吗,求解决方案。thx

共收到 2 条回复 时间 点赞
arrow Gatling 性能测试 从入门到精通 中提及了此贴 10月09日 17:44

constantUsersPerSec 这个是在每秒钟产生 500 个的用户请求,持续十分钟,估计你的端口撑不住吧,你先跑每秒 50 个持续一分钟这样子,看看正常不正常。可以参考我的文章https://testerhome.com/topics/16375

xiuxiuing 回复

好的 谢谢

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册