I studied a sample from this link http://socket.io/docs/
Example
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
var socket = io('ws://127.0.0.1:3000');
socket.emit('ui:index:loaded',{_id: '123456'});
socket.on('app:banner:loaded',function(obj){
console.log(obj);
});
socket.on('app:collection:loaded',function(obj){
console.log(obj);
});
</script>
How to use this in Jmeter?
Now, I request 2probe, it response 3probe.
I need to send event
Anyone have ideas.
There is a super late answer for anyone still needs it.
I used Chrome dev tools and tried to see what happened when a event emitted. I found that there was a http POST request sent when emitting event, so what I did was creating a same http request by jmeter, and it works.
In my case, the event name is "join", and the content is
{"sn":"1522729528413MDSCDGE","vsn":"093"}
Here is what I've found in Chrome's Network tab
And here is a HTTP Request Sampler I created by jmeter.
I think the number 52 means the string length of your event content. If you want to change your event content, remember to calculate a correct length, and I don't know what 42 means. I just copied it.
Hope this helps.
JMeter doesn't support WebSocket testing out-of-the-box, you will need either to use the plugin or to write some code in JSR223 Sampler
If you want to go the "plugin way":
Download and install JMeter Plugins Manager
From JMeter main menu select Options -> Plugins Manager -> Available Plugins -> Websocket Protocol Support
After the plugin installation you should be able to add the WebSocket Sampler. Appropriate configuration will look like:
Server Name or IP: localhost
Port Number: 3000
Protocol: ws
Request Data: {_id: '123456'}
You will also need to add some form of expected response into the "WebSocket Response" stanza.
See WebSocket Testing With Apache JMeter guide for more information on using the plugin and manually sending WebSocket messages via Groovy code.
Related
I have two thread groups in my project, and on of them has two HTTP request samplers. It's set up like the following
Thread group
Timer: Random between 1 and 5 minutes: ${__Random(60000,300000)}
HTTP request: A basic GET web service call
HTTP request: A basic GET web service call
Here's the Thread group setup.
That's it. Here's an example of the web service call setup
And here's what the "Statistics" portion of the HTML report looks like. Note the -1, -2 after the HTTP Request names. I'm trying to figure out why that's happening.
My other thread group / samplers are not displaying that way, but they're set up the same way, as far as I can tell.
In your example, HTTP requests Get Locations-0, Get Locations-1 are sub requests of Get Locations which appeared since you have selected the check box - Follow Redirects.
In case, you don't want HTTP requests Get Locations-0, Get Locations-1 to appear in your HTML report:
In the listener page(where you have saved the result file; which is the source file of HTML report) -> click on configure button -> uncheck the Save Sub Result option
You can also refer :Configure result file to customize HTML report
Turns out that some of the calls were returning a 200, others a 301, that's where they got separated out, even though the 301's didn't register as errors in the report.
I have configured PhpStorm to debug HTTP GET - but only when I load a page directly.
When I want to debug AJAX, I take the URL which my JS would request and create a PhpStorm configuration to debug it.
Not particularly elegant, is it?
And, of course, I can't do that for POST requests (or can I?).
Ideally, I would like to load my AngularJs app in the browser (Chrome) and be able to breakpoint and debug the backend in PhpStorm.
I googled a lot, and found much that came close, but I can't find the answer :-(
Who can help?
[Update] a few years later, and I am using the excellent and free Postman to test both GET and POST.
If Xdebug and PHPStorm are configured to debug HTTP GET when loading a page normally, then simply include the GET parameter in the URL of the AJAX request in your Javascript. For example: http://example.com/script.php?XDEBUG_SESSION_START=PHPSTORM
Turn on Debug listening in PHPStorm, send the AJAX request with the new URL, and the debugger should catch it. The POST data you are looking for should appear in $_POST as usual.
I am using kind of hacking method to debug AJAX requests. My project is Laravel. You can change this code as compatible with your technology.
Basic idea is:
Grab home page debug port
Create a session
Using this session concatenate the AJAX url
When you start debugging, the port will be applied for all ajax urls which having + debug_url.
HomeController#index method
// Development purpose only
if ($request->has('XDEBUG_SESSION_START')) $request->session()->put('debug_port' , $request->get('XDEBUG_SESSION_START'));
master.blade.php
<script>
var debug_url='?XDEBUG_SESSION_START={{session('debug_port')}}';
</script>
submit.blade.php
<script>
$.ajax(url + debug_url, {
method:'post',
data:{}
});
</script>
I want to send a JSON payload with HTTP GET request but I want to prevent it to be viewable in URL.
GET http://<domain>/school/search.json
{
schoolId: ["S1","S2","S3"],
location: "Pune"
}
How can I achieve this in JMeter Apache?
Get implies visible in Url, what exactly do you want to do ?
Sending Body data along with HTTP GET request is available for default (HttpClient4) implementation since ver.3.1 (as Bugzilla #60358), as well as request retrying behavior both for PUT and GET with body fixed since ver.3.2 (as Bugzilla #60837).
Just as additional note: you will likely encounter problems if you have cache/proxies in your setup and if you plan to take advantage from their usage.
We have a system that uses Firefox as a client for a Web application. The web page uses Dojo Ajax to perform a servlet POST request doing a long process. The problem is when the request exceeds 15 minutes (based on observation), the same Http request (same parameters) is performed repeatedly by the browser. The repeat request is received every 1 minute 20 seconds thereafter.
11:00:00 First Request
11:15:00 Repeat Request
11:16:20 Repeat Request
11:17:40 Repeat Request
11:19:00 Repeat Request
11:20:20 Repeat Request
My question is there a setting in the firefox config or even on the servlet part that can prevent the repeat request? This is a local system so I can control the browser settings.
Note: I know that a solution to this is to perform the long process in a thread and repeatedly poll the thread via javascript but my boss wants an easier fix if possible via settings in firefox.
Added based on comment:
The code used is the dojo toolkit dojo.xhrPost API to do the request. I am not sure if the dojo API is the one that is doing the reposting. Help from dojo expert too.
Added source based on Jeremy's comment:
dojo.xhrPost(
{
url: servlet,
content: {
jobName: 'DoLongProcess',
FUNCTIONNO: dojo.byId('hdFunctionNo').value
},
handleAs: handleAs,
handle: function(response) {
cursorStyle(cursor_style_auto);
}
}
);
The version of dojo I'm using is 1.3.1 Rev: 17468. Unfortunately I cannot change the dojo to higher version since that would require a regression test on all functions.
Trying to get my way trought Comet with Java servlets, I encountered a big problem: There seems to be no way to use the established connection to the client to send the server additional data from the browser (works in plain java when writing to the inputstream).
Following problem arises for a CometChat application when a Client connects to servlet, receives a form for sending input and a form for presenting server output: Now if the client wants to send some data at this connection, resulting in a READ event at the servlet, how can this be done?
I tried sending GET, HEAD and POST. With HEAD the comet connection is closed afterwards. GET always produces END, BEGIN and POST produces BEGIN, READ.
I tried searching the web, but the only answer I found was: Comet READ events are generating when there is a POST method with a body
How can I achieve this?
I'm using plain Javascript Ajax:
function send(content) {
var text = document.controller.input.value;
params = 'input=' + content;
var ajaxObj = createXMLHttp();
ajaxObj.open('POST', 'CometChat', true);
ajaxObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
ajaxObj.setRequestHeader('Content-Length', params.length);
ajaxObj.setRequestHeader('Connection', 'close');
ajaxObj.onreadystatechange = function() {};
ajaxObj.send(params);
}
This produces BEGIN, READ. What headers do I need to set to produce a solely READ event only?
I'm able to 'cheat' this by looking up my connections and reuse response, but on client side, the AJAX request stays in interactive mode (although flushing it on the server) and I'm only able to may 5 requests on FF and 10 requests on IE before the following request is not processed. Also as soon as the first AJAX request is received on the server, I'm get TIMEOUT events, two per request repeating forever.
What's the real way?
Good luck, creating a Comet app with Java Servlets is a pretty complicated undertaking. Plus Tomcat wasn't really designed for it. I suggest you check out StreamHub Comet Server.
As rajax says, developing a Comet app in servlets is a really bad idea.