总是收到错误“非 HTTP 响应代码:java.net.UnknownHostException”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36256721/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 01:09:44  来源:igfitidea点击:

Always getting error “Non HTTP response code: java.net.UnknownHostException”

javamultithreadingjmeterstress-testing

提问by Tharindu Kandegedara

I tried stress testing with JMeter software to test a web site as it crashed after a sms campaign. Currently site has been moved to a physical server.

我尝试使用 JMeter 软件进行压力测试来测试一个网站,因为它在短信活动后崩溃了。当前站点已移至物理服务器。

I tested multiple times by adding threads, it worked and gave few errors (for above 1000 threads), and worked for 400 threads with no error. So I tried distributed testing with 4 PCs including my one.

我通过添加线程进行了多次测试,它工作正常并且几乎没有错误(对于 1000 个以上的线程),并且在 400 个线程上工作没有错误。所以我尝试用 4 台 PC 进行分布式测试,包括我的一台。

After I tried again with only my PC to send requests to the site by adding 400 threads(ramp up = 1 , loop = 1). But each and every requests gives error. Then I tried using 1 thread. Same error was given.

在我再次尝试仅使用我的 PC 通过添加 400 个线程(ramp up = 1,loop = 1)向站点发送请求之后。但是每个请求都会出错。然后我尝试使用 1 个线程。给出了同样的错误。

enter image description here

在此处输入图片说明

I checked my network connection, and there is no problem. Then I browsed the web site "http://www.myjobs.lk/", and it works fine.

我检查了我的网络连接,没有问题。然后我浏览了网站“ http://www.myjobs.lk/”,它工作正常。

These are the values I have given in testing.

这些是我在测试中给出的值。

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

Under this condition, I cannot perform the testing because it always gives errors. How can I overcome this problem?

在这种情况下,我无法执行测试,因为它总是会出错。我怎样才能克服这个问题?

回答by Dmitri T

You're using incorrect JMeter configuration, change it as follows:

您使用的 JMeter 配置不正确,请按如下方式更改:

  1. Remove http://from "Server Name or IP" input
  2. Put httpto "Protocol input

    HTTP Request Defaults

    It is also possible to have the full URL in "Path" field like

    Path in HTTP Request Defaults

    But using "http://" in "Server Name or IP" won't work.

  1. http://从“服务器名称或 IP”输入中删除
  2. 放入http“协议输入

    HTTP 请求默认值

    也可以在“路径”字段中包含完整的 URL,例如

    HTTP 请求默认值中的路径

    但是在“服务器名称或 IP”中使用“http://”将不起作用。

Also once you defined hostname, port, path, etc. in HTTP Request Defaults it will be automatically applied to all HTTP Request Samplers. You will be able to override an option for particular this or that sampler but if you don't - default value will be used. See Why It's SO Important To Use JMeter's HTTP Request Defaultsfor more detailed explanation and some use cases.

此外,一旦您在 HTTP 请求默认值中定义了主机名、端口、路径等,它将自动应用于所有HTTP 请求采样器。您将能够覆盖特定于此或那个采样器的选项,但如果不这样做 - 将使用默认值。有关更详细的说明和一些用例,请参阅使用 JMeter 的 HTTP 请求默认值为何如此重要

回答by fascynacja

For me it was helpful to setup proxy server: Http Request Defaults->Advanced

对我来说,设置代理服务器很有帮助: Http 请求默认值->高级

回答by gustf

Looks like JMetertries to connect to myjobs.lk, and you browse to www.myjobs.lk. Try changing so that JMeteralso connects to www.myjobs.lk

看起来JMeter尝试连接到myjobs.lk,而您浏览到www.myjobs.lk。尝试更改以便JMeter也连接到www.myjobs.lk