How can i use chinese string in tsung - tsung

I'm china developer, i use tsung to test my application.
but now , i have problem,
this is my xml code.
<options>
<option name="file_server" id="usernames" value="/usr/local/tsung/username.csv" />
</options>
<sessions>
<session name='rec20160406-1853' probability='100' type='ts_http'>
<setdynvars sourcetype="file" fileid="usernames" delimiter=";">
<var name="user_name"/>
</setdynvars>
<request subst="true">
<http url='http://10.2.0.96:3000/sessions?username=%%_user_name%%'>
</http>
</request>
</session>
</sessions>
username.csv
四方茉莉-Ra
宁靜致遠
阿莫西林
脸骑士
大嗨朵
右眼淤青
程子
这明显不科学
冰与火奏鸣曲
I want send user_name to my application, the user_name is read from csv file, the csv file is chinese content.
I start tsung, and watch the nginx access-log.
log:
192.168.60.61 - - [21/Apr/2016:17:17:29 +0800] "GET /sessions?username=\xE5\x86\xB0\xE4\xB8\x8E\xE7\x81\xAB\xE5\xA5\x8F\xE9\xB8\xA3\xE6\x9B\xB2 HTTP/1.1" 500 70 "-" "tsung"
the user_name encode to be \xE5\x86\xB0\xE4\xB8\x8E\xE7\x81\xAB\xE5\xA5\x8F\xE9\xB8\xA3\xE6\x9B\xB2, my application can not resolve this.
please help me , how can i to do.

Related

What is the limit of TCP connections per machine using TSUNG?

I want to generate a lot of requests using TSUNG.
My configuration file is
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" dumptraffic="false" version="1.0">
<clients>
<client host="localhost" maxusers="70000" use_controller_vm="true"/>
</clients>
<servers>
<server host="myhost" port="5222" type="tcp"/>
</servers>
<load>
<arrivalphase phase="1" duration="70000" unit="second">
<users arrivalrate="10" unit="second"/>
</arrivalphase>
</load>
<options>
<option type="ts_jabber" name="global_number" value="70000"/>
<option type="ts_jabber" name="domain" value="my-domain"/>
<option name="file_server" id="userdb" value="/root/userdata.csv"/>
</options>
<sessions>
<session probability="100" name="xmpp-connection" type="ts_jabber" bidi="true" $
<setdynvars sourcetype="file" fileid="userdb" delimiter=";" order="iter">
<var name="userid"/>
</setdynvars>
<transaction name="initial_stream">
<request subst="true">
<jabber type="connect" ack="local">
<xmpp_authenticate username="tsung%%_userid%%" passwd="tsung%%_userid%%"/>
</jabber>
</request>
</transaction>
<thinktime value="2"/>
<transaction name="authenticate">
<request> <jabber type="auth_sasl" ack="local"/> </request>
<request> <jabber type="connect" ack="local"/> </request>
<request> <jabber type="auth_sasl_bind" ack="local"/> </request>
<request> <jabber type="auth_sasl_session" ack="local"/> </request>
</transaction>
<transaction name="roster_get">
<request> <jabber type="iq:roster:get" ack="local"/> </request>
</transaction>
<request> <jabber type="presence:initial" ack="no_ack"/> </request>
<for from="1" to="28" incr="1" var="counter">
<request> <jabber type="raw" ack="no_ack" data="
"/></request>
<thinktime value="60" random="false"/>
</for>
<for from="1" to="30" incr="1" var="counter">
<request> <jabber type="raw" ack="no_ack" data="
"/></request>
<thinktime value="60" random="false"/>
</for>
<transaction name="close">
<request> <jabber type="close" ack="no_ack"/> </request>
</transaction>
</session>
</sessions>
</tsung>
As per the documentation of TSUNG, I can hit the server using multiple client ips (one machine)
http://tsung.erlang-projects.org/user_manual/conf-client-server.html
Several virtual IP can be used to simulate more machines. This is very useful when a load-balancer use the client’s IP to distribute the traffic among a cluster of servers.
<clients>
<client host="louxor" weight="1" maxusers="800">
<ip value="10.9.195.12"></ip>
<ip value="10.9.195.13"></ip>
</client>
<client host="memphis" weight="3" maxusers="600" cpu="2"/>
</clients>
I want to find out how many connections per one machine I can generate using TSUNG.
I have a 32 GB, 8 core machine.
This will depend on two factors:
The maximum number of simultaneously open Erlang ports.
The maximum amount of open file description in your operating system.
For information about the first one see open ports in the 10.2 System Limits section of the Advanced Erlang document. It can be changed using the +Q option when starting the Erlang VM. The default is 16384. And the current limit can be checked using erlang:system_info/1:
erlang:system_info(port_limit).
For second information simply ulimit -n in the shell. How to change this value depends on the operating system but it's a popular topic so you will easily be able to search for instructions.

Resource not found on localhost using Anypoint Studio (MULE)

I tried to do the tutorials suggested on the MuleSoft's website.
I first started with this example:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8084" doc:name="HTTP Listener Configuration"/>
<flow name="basic_tutorialFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<expression-filter expression="#[payload != '/favicon.ico']" doc:name="Expression"/>
<logger level="INFO" doc:name="Logger" message="Current payload is #[payload]"/>
<set-payload doc:name="Set Payload" value="#['Hello, ' + message.inboundProperties.'http.request.path' + '. Today is ' + server.dateTime.format('dd/MM/yy') + '.' ]"/>
</flow>
</mule>
Which can be found here http://www.mulesoft.org/documentation/display/current/Basic+Studio+Tutorial
I made it using the drag and drop feature and after that I copied the code on the website just to be sure it wasn't my mistake.
When I enter the URL with no payload it works well. I get this response
Hello, /. Today is 23/01/15.
But when I add a payload like in the tutorial it doesn't work :
Resource not found.
I have tried other examples as well, as long as I don't enter a payload it works. Here is what the console tells me :
INFO 2015-01-23 10:33:55,614 [[basic_tutorial].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: Current payload is {NullPayload}
INFO 2015-01-23 10:34:32,794 [[basic_tutorial].HTTP_Listener_Configuration.worker.01] org.mule.module.http.internal.listener.HttpListenerRegistry: No listener found for request: (GET)/asd
INFO 2015-01-23 10:34:32,796 [[basic_tutorial].HTTP_Listener_Configuration.worker.01] org.mule.module.http.internal.listener.HttpListenerRegistry: Available listeners are: [(*)/]
INFO 2015-01-23 10:34:36,205 [[basic_tutorial].HTTP_Listener_Configuration.worker.01] org.mule.module.http.internal.listener.HttpListenerRegistry: No listener found for request: (GET)/world
INFO 2015-01-23 10:34:36,205 [[basic_tutorial].HTTP_Listener_Configuration.worker.01] org.mule.module.http.internal.listener.HttpListenerRegistry: Available listeners are: [(*)/]
So basically the problem is :
INFO 2015-01-23 10:34:36,205 [[basic_tutorial].HTTP_Listener_Configuration.worker.01] org.mule.module.http.internal.listener.HttpListenerRegistry: No listener found for request: (GET)/world
So with 3.6, the HTTP connector has changed drastically. Here are some changes:
Previously, the HTTP connector would place the contents of the path inside your payload. Moreover, now you need to invoke paths as is. What I mean is that nowadays, if your endpoint is listening on http://localhost:8084/, that's where you need to send the request. Sending a request on http://localhost:8084/HelloWorld will NOT match.
Sending a GET request now will set your payload to NullPayload, which admittedly makes sense, since an HTTP GET does not have an HTTP body.
What I suggest is the following: have your endpoint listening on a path as follows:
<http:listener config-ref="HTTP_Listener_Configuration" path="/{name}" doc:name="HTTP"/>
Notice that I've added a placeholder variable called "name", you can change this to whatever you like. You can then access this placeholder as follows:
#[message.inboundProperties['http.uri.params']['name']]
You can use this expression to return some fancy string, as you're doing above:
<flow name="basic_tutorialFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/{name}" doc:name="HTTP"/>
<set-variable variableName="name" value="#[message.inboundProperties['http.uri.params']['name']]" />
<set-payload doc:name="Set Payload" value="#['Hello, ' + flowVars['name'] + '. Today is ' + server.dateTime.format('dd/MM/yy') + '.' ]"/>
</flow>
Cheers,
JS
As told before, the HTTP Connector is deeply changed from version 3.6 onward.
Now, the connector only listen to the specific path you explicitly define.
My issue was that I wasn't even able to get the WSDL by the obious http://localhost:8080/soap?wsdl.
So, the easiest solution I found to solve this issue was to allow the connector to accept all subpaths by ending the path with the wildcard '*'.
Change your project.xml as I show here:
<http:listener config-ref="HTTP_Listener_Configuration" path="/*" doc:name="HTTP"/>
and all subpaths will be processed.

Cut Servlet url in JBoss

I've got an app which is running on JBoss 7. Its URL is http://localhost:8080/archive/app. How can I make it look http://localhost:8080/app or http://localhost/app?
PS. /archive means archive.war
1) Remove the welcome root. In the standalone.xml set:
<virtual-server name="default-host" enable-welcome-root="false">
2) Set the context root. In your archive.war add a jboss-web.xml file in the WEB-INF folder:
<?xml version="1.0"?>
<jboss-web>
<context-root>/</context-root>
</jboss-web>
3) Set the http port to 80. In the standalone.xml change:
<socket-binding name="http" port="8080"/> to <socket-binding name="http" port="80"/>
Remember that if your server runs on a Linux machine it must be launched by root in order to use ports under 1024. In that case you can redirect from 80 to 8080 by means of iptables without the need to change the standalone.xml socket-binding

What's the meaning of "simultaneous" in Tsung?

Here is my tsung.xml:
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="warning" version="1.0">
<clients>
<client host="localhost" use_controller_vm="true" maxusers="30000"/>
</clients>
<servers>
<server host="127.0.0.1" port="9988" type="tcp"/>
</servers>
<!--
<monitoring>
<monitor host="localhost" type="erlang"></monitor>
</monitoring>
-->
<load duration="90" unit="second">
<arrivalphase phase="1" duration="1" unit="minute">
<users arrivalrate="300" unit="second" />
</arrivalphase>
</load>
<options>
<option name="thinktime" value="0" random="false" override="true"/>
<option name="tcp_snd_buffer" value="4096"/>
<option name="tcp_rcv_buffer" value="4096"/>
<option name="ports_range" min="1025" max="65535"/>
</options>
<sessions>
<session name="mysocket" probability="100" type="ts_raw">
<request>
<raw datasize="1" ack="local"></raw>
</request>
</session>
</sessions>
</tsung>
It tests my socket program, but I cannot fully understand the Tsung report.
Please help to look at this pic, what does "simultaneous" mean?
If anyone can help to tell me something about the report stats, that will be fine.
Stats like following(fetched from Tsung's manual):
users: Number of simultaneous users.
connected: Number of simultaneous connected users. new in 1.2.2.
Is it good or bad if users and connected is low?
Thank you in advance.
The http server will close the TCP socket if there is no action on it for a while or if it is overloaded. The opening and closing of TCP Sockets is handled automatically by Tsung. That said the 'connected' value is the current number 'users' that are connected to the server. Hope this helps

Jetty HTTP 413 Header Full error - Java/Scala

I am using Jetty 7.6 with Scalatra web framework. In some of the requests, I need to send a large text as response body to the client, I use HttpServletResponse.getWriter() to write response.
I noticed that on client side I receive 413 Header Full error. Apparently one solution to this problem in Jetty is to increase jetty's header-buffer-size value.
I would like to know what does HttpServletResponse.getWriter() has to do with the size of the header of request ?! As I understand HttpServletResponse.getWriter() writes into response body rather than response header.
I appreciate if someone could explain this issue.
Unfortunately, this is not only headers that matters (like joakime thougth).
Jetty has a buffer for headers and a buffer for request.
If the full request (http data stream) fits in the hearder's buffer no problem.
If it exceeds the header's buffer, the request buffer will be user.
If it exceeds the request buffer then you got a standard Http response with status 413.
There is the same thing (buffer) for the answer but hopefully Http is designed to send "chunked" response.
I'm facing the same problem with an upload.
What I've found is that you can set the size of those buffers.
See:
http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/nio/SelectChannelConnector.html
http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/nio/AbstractNIOConnector.html
http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/server/AbstractConnector.html#setRequestHeaderSize(int)
You can use jetty.xml file to do it :
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
<Set name="requestHeaderSize">8192</Set>
</New>
</Arg>
</Call>
</Configure>
HTTP response code 413 is HttpStatus.REQUEST_ENTITY_TOO_LARGE.
It has nothing to do with your HttpServletResponse.getWriter().
Capture and check the request headers, you are sending a unreasonable amount of headers to the server.
If you're using or upgraded to Jetty 9, they've removed the SelectChannelConnector. Here is the updated jetty.xml -
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
<Set name="requestHeaderSize">8192</Set>
</New>
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ServerConnector">
<Arg name="server"><Ref id="Server" /></Arg>
<Arg name="factories">
<Array type="org.eclipse.jetty.server.ConnectionFactory">
<Item>
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
<Arg name="config"><Ref id="httpConfig" /></Arg>
</New>
</Item>
</Array>
</Arg>
<Set name="port">8080</Set>
</New>
</Arg>
</Call>
See http://www.eclipse.org/jetty/documentation/current/configuring-connectors.html

Resources