为什么我收到响应代码:非HTTP响应代码:java.net.SocketException? [英] Why am I receiving Response code: Non HTTP response code: java.net.SocketException?

查看:2706
本文介绍了为什么我收到响应代码:非HTTP响应代码:java.net.SocketException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JMeter将请求发送到我在 localhost 上运行的应用程序,但由于 java.net.SocketException ,许多请求都失败了。我在控制台中没有看到任何异常。

I am trying to send requests using JMeter to my application that is running on localhost but many of the requests get failed due to java.net.SocketException. I do not see any exceptions in console though.

我读过这些 question1 question2 但没有多大帮助。

I read these question1 and question2 but did not help much.

我的代码如下:

 try {
        return myService.findItems(group);

    } catch (NullPointerException n) {
        n.printStackTrace();
    } catch (HibernateException h) {
        h.printStackTrace();
    } catch (IOException i) {
        i.printStackTrace();
    }
    return null;

存储库

  public LinkedHashMap findItems(String group) throws NullPointerException, HibernateException, IOException {
        Session session = sessionFactory.getCurrentSession();
                 ..... //request is sent to database

        return items;
    }

我的JMeter配置的屏幕截图

推荐答案

从您提供的屏幕截图中,我认为您认为您的系统/ localhost是超级计算机,或者您错误配置了jmeter设置。

From Screenshots you provided, I think either you thought your system/localhost as super computer or you have mis-configured the jmeter settings.

屏幕截图显示,10000个用户/线程将在1秒内启动,这对于在localhost上运行的应用程序来说是完全不真实的。单独的Jmeter会占用大部分CPU,内存,即系统资源。

Screenshot shows, 10000 users/threads will start in 1 second which is completely unreal for application running on a localhost. Jmeter alone will eat most CPU, memory i.e. system resources.

如果您的Jmeter正在吃掉所有资源,您的应用程序将获得任何内容(简单答案为否)因此应用程序将关闭,您将开始获得超时错误或套接字异常。

If your Jmeter is eating all resources will your application will get anything (Simple answer is NO) Thus application will go down and you will start getting timeout errors or socket exceptions.

如果你在diff机器上有jmeter和应用程序,那么在1秒内仍有10000个用户对于正常应用来说是非常高的负载,很明显你会遇到这样的错误。尝试使用给定hw的应用程序预期的实际负载运行测试。可能在1秒内有100个用户并逐渐将其增加到预期值。

If you have jmeter and application on diff machines then still 10000 users in 1 second is very high load for a normal application and it is obvious that you will face such errors. Try running test with realistic load that is expected for your application with given hw. Maybe 100 users in 1 second and gradually increase them to expected value.

我希望你现在明白了:)

I hope you understood it now :)

这篇关于为什么我收到响应代码:非HTTP响应代码:java.net.SocketException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆