首页 \ 问答 \ JMeter测试失败的HTTP请求(HTTP request on JMeter test failure)

JMeter测试失败的HTTP请求(HTTP request on JMeter test failure)

在我的JMeter测试中,如果有任何错误,我想触发HTTP请求在我的系统上发布消息以进一步关注。 我能在这做什么? 邮件可视化工作正常,可通过电子邮件报告错误。 我想做同样但通过HTTP请求。 我正在使用jmeter 3.2。


In my JMeter test, if there is any error, I want to trigger HTTP request to post a message on my system for further attention. What can I do here? Mail visualiser works fine to report errors over email. I want to do the same but over HTTP request. I am using jmeter 3.2.


原文:https://stackoverflow.com/questions/46037002
更新时间:2022-10-22 13:10

最满意答案

要建立与服务器的连接,您需要在服务器端有一个脚本来接收输入连接并对其执行某些操作。 所以第一步是编写一个简单的脚本(我建议使用PHP)。

现在,您必须创建从android到所述服务器的连接。 您可以使用AsyncTask或生成新线程来执行任何与网络相关的操作,因为没有网络操作可以在UI线程上运行。 示例代码:

public class BackgroundTask extends AsyncTask<Void,Void,Void>{

@Override
protected Void doInBackground(Void... params) {
  //perform network operation and return response
  URL url = new URL("link.to.your.VPS.script");
  //now make a connection
  HttpUrlConnection conn = (HttpUrlConnection) url.openConnection();
  //get response code
  conn.getResponseCode();

  return null;
}

@Override
protected void onPostExecute(Void v){

}
}

您可以从您的活动中运行此代码

new BackgroundTask().execute();

这只是一个启动者。 您可以通过将参数发布到PHP代码并将PHP代码连接到MySql DB来改进这一点

PS一年前我就在你的位置,因此我非常乐意提供帮助。 但是下次你在StackOverfllow上发帖时,请确保你的问题是具体的。


To establish a connection to server, you need to have a script at the server end to receive and perform some action on input connection. So first step would be to write a simple script (I would suggest PHP).

Now, you must create a connection from android to the said server. You can use AsyncTask or spawn a new thread to perform any network related operations, because no network operation can run on UI thread. Sample code:

public class BackgroundTask extends AsyncTask<Void,Void,Void>{

@Override
protected Void doInBackground(Void... params) {
  //perform network operation and return response
  URL url = new URL("link.to.your.VPS.script");
  //now make a connection
  HttpUrlConnection conn = (HttpUrlConnection) url.openConnection();
  //get response code
  conn.getResponseCode();

  return null;
}

@Override
protected void onPostExecute(Void v){

}
}

You can run this code from your activity by

new BackgroundTask().execute();

This is just a starter. You can improve on this by posting parameters to your PHP code and connect PHP code to MySql DB

P.S. I was in your place a year ago and hence I am more than happy to help. But the next time you post on StackOverfllow, make sure your question is specific.

相关问答

更多
  • 当您在服务器上复制新的网站版本时,您的连接字符串可能已被覆盖。 请检查web.config中的连接字符串,看看它是否有效。 Your connection string was probably overriden when you copied your new website version on the server. Please check the connection string in web.config and see if it is valid.
  • 经过几天的跟踪和使用Wireshark后,我设法通过在Windows服务器中添加本地用户来解决这个问题。 在这种情况下,本地用户的名称无关紧要(不必与DB2连接中使用的用户名相同)。 如果本地用户属于Administrator-group,则问题仍然存在,因此我创建了没有该组的本地用户。 听起来只有域上的用户或admin-group上的用户才能被活动目录检查。 After few days of tracing and using Wireshark I managed to solve this by a ...
  • 这听起来像我自己回来的那个问题。 我的问题是我的SQL Service Pack 1安装不正确所以我必须安装Microsoft SQL Server系统CLR类型,Microsoft SQL Server 2008管理对象和Microsoft SQL Server 2008 Native Client。 之后我可以创建新的SQLdatasources,但我无法编辑我之前遇到的问题。 我必须以安全模式重新启动计算机并删除我的SQLEXPRESS文件夹,然后在可视工作室中重新创建数据库连接。 当我完成后,一切正 ...
  • hping3发送原始数据包,而不打开内核的面向连接的套接字 - 因此是RST。 为了让内核建立连接,您必须在应用程序端打开一个套接字。 这意味着应用程序必须继续运行,如果它关闭,内核将重置所有打开的套接字。 您的选项是限制,您可以尝试'nc'(netcat),并为您要打开的每个连接启动一个新进程。 或者以其他方式编写打开多个连接的程序,每个程序使用不同的套接字以确保每个连接的源端口不同。 请记住,您可以在单个程序中以及整个系统上打开多少个套接字。 hping3 sends raw packets, with ...
  • 要建立与服务器的连接,您需要在服务器端有一个脚本来接收输入连接并对其执行某些操作。 所以第一步是编写一个简单的脚本(我建议使用PHP)。 现在,您必须创建从android到所述服务器的连接。 您可以使用AsyncTask或生成新线程来执行任何与网络相关的操作,因为没有网络操作可以在UI线程上运行。 示例代码: public class BackgroundTask extends AsyncTask{ @Override protected Void doInBackgro ...
  • 如何(以及在何处)管理开放套接字? 我应该把它们放在HashMap中吗? 通常,每个套接字都由一个负责读取和写入套接字的线程管理。 您还将拥有一个主线程,负责在预定义的网络接口和端口(使用ServerSocket API类)接收所有连接请求,然后可以将实际处理工作移交给工作者/从属线程。 在这种情况下,您应该查看工作线程的线程池,因为创建50k线程很可能会压倒您的操作系统和硬件。 此外,如果您确实在管理50k并发套接字,那么强烈建议在Java的普通IO API上使用NIO API(java.nio。*),尽 ...
  • 看起来最好的选择是将远程服务转换为WCF服务,以便公开更常见的通信方式。 或者创建一个WCF包装器服务,该服务将与远程处理服务通信并转发响应。 Looks like the best option would be to convert the remoting service to a WCF service in order to expose a more common way of communicating. Or create a WCF wrapper service that would t ...
  • 建立这样合理,稳定和可扩展的多个连接? 是的,这是一种非常合理的方法。 很少有数据库系统受传出连接数量的限制。 JDBC和Korma都会在clojure中处理这个问题。 在构建监视和操作相关组件时,您确实需要了解哪些请求依赖于哪个DB。 因此,您可以确定哪个数据库导致了问题。 是否有其他更好的方法用于项目数据库的路由和动态绑定? 我唯一的建议是明确地将DB传递给每个函数而不是使用绑定,尽管这是个人风格的意见,你的方法显然会有效。 Is establishing multiple connections li ...
  • 我认为白名单方法是一次处理建立多个连接的唯一方法。 HCI只能处理一次建立一个连接(如果我没记错的话),在建立连接之前你没有任何连接句柄。 L2CAP套接字是一种利用HCI方法的内核抽象。 如果您尝试在其中一个处于挂起状态时启动另一个连接,我认为您会收到错误。 我怀疑即使DBUS方法提到的只是对HCI方法的抽象,它仍然是一个按顺序建立连接的过程。 即使您使用白名单方法,我也不确定实际上它的速度有多快,因为问题是连接间隔以及广告间隔。 白名单通过侦听广告包并在检测到连接时建立连接来工作。 我也从未使用白名单方 ...
  • 不,您不需要本地数据库。 你得到的错误可能是一些问题。 您应该确保连接对数据库是正确的,并确保服务器配置正确,以便系统可以使用正确的权限访问它。 但是,如果您到达数据库以将表添加到您的应用程序,并且报告本地数据库的错误是错误的连接,我的猜测可能是项目的发布部分是生成连接字符串的位置。 如果是这种情况,我会考虑更改连接字符串以进行测试,这将在此处讨论: 如何在调试模式下更改lightswitch应用程序的连接字符串 No, you do not need a local database. The error ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)