ejabberd BOSH takes too many minutes in HTTP pre-bind - xmpp

The context:
I'm trying to generate a session from my back-end to attach to it from my front-end. In the process, I'm sending the request to ejabberd, to the mod_http_bind module listening on the port 5280, as is explained in metajack.im post.
Session id requests are sent using this script.
I'm using external authentication and is working well, in a normal time, when connecting directly through XMPP or WebAdmin.
The problem:
It's generating the session id right BUT it's taking around 1-3 minutes. After this time my Bosh chat client through a timeout. Beside this, it's too much time for a simple session id.
Any suggestion??
Extra info:
Here is my ejabberd logs:
ejabberd-log
2015-12-14 15:52:34.655 [info] <0.490.0>#ejabberd_listener:accept:299 (#Port<0.3971>) Accepted connection 127.0.0.1:49840 -> 127.0.0.1:5280
2015-12-14 15:52:34.655 [info] <0.713.0>#ejabberd_http:init:157 started: {gen_tcp,#Port<0.3971>}
2015-12-14 15:53:43.187 [info] <0.490.0>#ejabberd_listener:accept:299 (#Port<0.3972>) Accepted connection 127.0.0.1:49855 -> 127.0.0.1:5280
2015-12-14 15:53:43.187 [info] <0.715.0>#ejabberd_http:init:157 started: {gen_tcp,#Port<0.3972>}
error.log
--empty--
crash.log
--empty--
Ejabberd version:
15.11
ejabberd.log with log_level at debug
2015-12-14 16:20:19.170 [info] <0.1240.0>#ejabberd_listener:accept:299 (#Port<0.7839>) Accepted connection 127.0.0.1:50027 -> 127.0.0.1:5280
2015-12-14 16:20:19.170 [debug] <0.1241.0>#ejabberd_http:init:153 S: [{[<<"register">>],mod_register_web},{[<<"admin">>],ejabberd_web_admin},{[<<"http-bind">>],mod_http_bind}]
2015-12-14 16:20:19.170 [info] <0.1241.0>#ejabberd_http:init:157 started: {gen_tcp,#Port<0.7839>}
2015-12-14 16:20:19.170 [debug] <0.1241.0>#ejabberd_http:process_header:280 (#Port<0.7839>) http query: 'POST' <<"/http-bind">>
2015-12-14 16:20:19.170 [debug] <0.1241.0>#ejabberd_http:extract_path_query:392 client data: <<"<body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' to='chatdomain' window='5' xml:lang='en' rid='1598394' hold='1' wait='70'/>">>
2015-12-14 16:20:19.170 [debug] <0.1241.0>#ejabberd_http:process:350 [<<"http-bind">>] matches [<<"http-bind">>]
2015-12-14 16:20:19.170 [debug] <0.1241.0>#mod_http_bind:process:68 Incoming data: <body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' to='chatdomain' window='5' xml:lang='en' rid='1598394' hold='1' wait='70'/>
2015-12-14 16:20:19.171 [debug] <0.1241.0>#ejabberd_http_bind:parse_request:1114 --- incoming data ---
<body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' to='chatdomain' window='5' xml:lang='en' rid='1598394' hold='1' wait='70'/>
--- END ---
2015-12-14 16:20:19.171 [debug] <0.1241.0>#ejabberd_http_bind:start:154 Starting session
2015-12-14 16:20:19.176 [debug] <0.1242.0>#ejabberd_http_bind:init:339 started: {<<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>,<<>>,{{127,0,0,1},50027}}
2015-12-14 16:20:19.176 [debug] <0.1241.0>#ejabberd_http_bind:handle_session_start:282 got pid: <0.1242.0>
2015-12-14 16:20:19.176 [debug] <0.1241.0>#ejabberd_http_bind:handle_session_start:321 Create session: <<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>
2015-12-14 16:20:19.176 [debug] <0.1241.0>#ejabberd_http_bind:http_put:775 Looking for session: <<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>
2015-12-14 16:20:19.176 [debug] <0.1242.0>#ejabberd_http_bind:handle_sync_event:442 New request: {http_put,1598394,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"to">>,<<"chatdomain">>},{<<"window">>,<<"5">>},{<<"xml:lang">>,<<"en">>},{<<"rid">>,<<"1598394">>},{<<"hold">>,<<"1">>},{<<"wait">>,<<"70">>}],[],155,1,{<<"chatdomain">>,<<>>},{{127,0,0,1},50027}}
2015-12-14 16:20:19.176 [debug] <0.1242.0>#ejabberd_http_bind:handle_http_put_event:558 New request: {http_put,1598394,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"to">>,<<"chatdomain">>},{<<"window">>,<<"5">>},{<<"xml:lang">>,<<"en">>},{<<"rid">>,<<"1598394">>},{<<"hold">>,<<"1">>},{<<"wait">>,<<"70">>}],[],155,1,{<<"chatdomain">>,<<>>},{{127,0,0,1},50027}}
2015-12-14 16:20:19.176 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:591 Actually processing request: {http_put,1598394,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"to">>,<<"chatdomain">>},{<<"window">>,<<"5">>},{<<"xml:lang">>,<<"en">>},{<<"rid">>,<<"1598394">>},{<<"hold">>,<<"1">>},{<<"wait">>,<<"70">>}],[],155,1,{<<"chatdomain">>,<<>>},{{127,0,0,1},50027}}
2015-12-14 16:20:19.176 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:642 -- SaveKey:
2015-12-14 16:20:19.176 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:654 reqlist: [{hbr,1598394,<<>>,[]}]
2015-12-14 16:20:19.176 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:700 really sending now: []
2015-12-14 16:20:19.278 [debug] <0.1241.0>#ejabberd_http_bind:prepare_response:900 OutPacket: [{xmlstreamstart,<<"stream:stream">>,[{<<"xml:lang">>,<<"en">>},{<<"xmlns">>,<<"jabber:client">>},{<<"xmlns:stream">>,<<"http://etherx.jabber.org/streams">>},{<<"id">>,<<"108440446">>},{<<"from">>,<<"chatdomain">>}]}]
2015-12-14 16:20:19.279 [info] <0.1240.0>#ejabberd_listener:accept:299 (#Port<0.7846>) Accepted connection 127.0.0.1:50028 -> 127.0.0.1:5280
2015-12-14 16:20:19.279 [debug] <0.1244.0>#ejabberd_http:init:153 S: [{[<<"register">>],mod_register_web},{[<<"admin">>],ejabberd_web_admin},{[<<"http-bind">>],mod_http_bind}]
2015-12-14 16:20:19.279 [info] <0.1244.0>#ejabberd_http:init:157 started: {gen_tcp,#Port<0.7846>}
2015-12-14 16:20:19.279 [debug] <0.1244.0>#ejabberd_http:process_header:280 (#Port<0.7846>) http query: 'POST' <<"/http-bind">>
2015-12-14 16:20:19.279 [debug] <0.1244.0>#ejabberd_http:extract_path_query:392 client data: <<"<body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' rid='1598395' xml:lang='en' sid='92c4475848d8b8f10b4dbe1a66980c385f46ac00'><auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AGFkbWluADEyMzQ=\n</auth></body>">>
2015-12-14 16:20:19.279 [debug] <0.1244.0>#ejabberd_http:process:350 [<<"http-bind">>] matches [<<"http-bind">>]
2015-12-14 16:20:19.279 [debug] <0.1244.0>#mod_http_bind:process:68 Incoming data: <body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' rid='1598395' xml:lang='en' sid='92c4475848d8b8f10b4dbe1a66980c385f46ac00'><auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AGFkbWluADEyMzQ=
</auth></body>
2015-12-14 16:20:19.279 [debug] <0.1244.0>#ejabberd_http_bind:parse_request:1114 --- incoming data ---
<body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' rid='1598395' xml:lang='en' sid='92c4475848d8b8f10b4dbe1a66980c385f46ac00'><auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AGFkbWluADEyMzQ=
</auth></body>
--- END ---
2015-12-14 16:20:19.279 [debug] <0.1244.0>#ejabberd_http_bind:http_put:775 Looking for session: <<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>
2015-12-14 16:20:19.279 [debug] <0.1242.0>#ejabberd_http_bind:handle_sync_event:442 New request: {http_put,1598395,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"rid">>,<<"1598395">>},{<<"xml:lang">>,<<"en">>},{<<"sid">>,<<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>}],[{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"PLAIN">>}],[{xmlcdata,<<"AGFkbWluADEyMzQ=\n">>}]}],255,1,<<>>,{{127,0,0,1},50028}}
2015-12-14 16:20:19.280 [debug] <0.1242.0>#ejabberd_http_bind:handle_http_put_event:558 New request: {http_put,1598395,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"rid">>,<<"1598395">>},{<<"xml:lang">>,<<"en">>},{<<"sid">>,<<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>}],[{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"PLAIN">>}],[{xmlcdata,<<"AGFkbWluADEyMzQ=\n">>}]}],255,1,<<>>,{{127,0,0,1},50028}}
2015-12-14 16:20:19.280 [debug] <0.1242.0>#ejabberd_http_bind:rid_allow:852 Previous rid / New rid: 1598394/1598395
2015-12-14 16:20:19.280 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:591 Actually processing request: {http_put,1598395,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"rid">>,<<"1598395">>},{<<"xml:lang">>,<<"en">>},{<<"sid">>,<<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>}],[{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"PLAIN">>}],[{xmlcdata,<<"AGFkbWluADEyMzQ=\n">>}]}],255,1,<<>>,{{127,0,0,1},50028}}
2015-12-14 16:20:19.280 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:642 -- SaveKey:
2015-12-14 16:20:19.280 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:654 reqlist: [{hbr,1598395,<<>>,[]},{hbr,1598394,<<>>,[{xmlstreamstart,<<"stream:stream">>,[{<<"xml:lang">>,<<"en">>},{<<"xmlns">>,<<"jabber:client">>},{<<"xmlns:stream">>,<<"http://etherx.jabber.org/streams">>},{<<"id">>,<<"108440446">>},{<<"from">>,<<"chatdomain">>}]}]}]
2015-12-14 16:20:19.280 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:700 really sending now: [{xmlel,<<"auth">>,[{<<"xmlns">>,<<"urn:ietf:params:xml:ns:xmpp-sasl">>},{<<"mechanism">>,<<"PLAIN">>}],[{xmlcdata,<<"AGFkbWluADEyMzQ=\n">>}]}]
^[OF2015-12-14 16:21:29.387 [info] <0.1240.0>#ejabberd_listener:accept:299 (#Port<0.7847>) Accepted connection 127.0.0.1:50030 -> 127.0.0.1:5280
2015-12-14 16:21:29.388 [debug] <0.1245.0>#ejabberd_http:init:153 S: [{[<<"register">>],mod_register_web},{[<<"admin">>],ejabberd_web_admin},{[<<"http-bind">>],mod_http_bind}]
2015-12-14 16:21:29.388 [info] <0.1245.0>#ejabberd_http:init:157 started: {gen_tcp,#Port<0.7847>}
2015-12-14 16:21:29.388 [debug] <0.1245.0>#ejabberd_http:process_header:280 (#Port<0.7847>) http query: 'POST' <<"/http-bind">>
2015-12-14 16:21:29.388 [debug] <0.1245.0>#ejabberd_http:extract_path_query:392 client data: <<"<body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' rid='1598396' xml:lang='en' sid='92c4475848d8b8f10b4dbe1a66980c385f46ac00'/>">>
2015-12-14 16:21:29.388 [debug] <0.1245.0>#ejabberd_http:process:350 [<<"http-bind">>] matches [<<"http-bind">>]
2015-12-14 16:21:29.388 [debug] <0.1245.0>#mod_http_bind:process:68 Incoming data: <body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' rid='1598396' xml:lang='en' sid='92c4475848d8b8f10b4dbe1a66980c385f46ac00'/>
2015-12-14 16:21:29.388 [debug] <0.1245.0>#ejabberd_http_bind:parse_request:1114 --- incoming data ---
<body xmlns='http://jabber.org/protocol/httpbind' content='text/xml; charset=utf-8' rid='1598396' xml:lang='en' sid='92c4475848d8b8f10b4dbe1a66980c385f46ac00'/>
--- END ---
2015-12-14 16:21:29.388 [debug] <0.1245.0>#ejabberd_http_bind:http_put:775 Looking for session: <<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>
2015-12-14 16:21:29.389 [debug] <0.1242.0>#ejabberd_http_bind:handle_sync_event:442 New request: {http_put,1598396,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"rid">>,<<"1598396">>},{<<"xml:lang">>,<<"en">>},{<<"sid">>,<<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>}],[],160,1,<<>>,{{127,0,0,1},50030}}
2015-12-14 16:21:29.389 [debug] <0.1242.0>#ejabberd_http_bind:handle_http_put_event:558 New request: {http_put,1598396,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"rid">>,<<"1598396">>},{<<"xml:lang">>,<<"en">>},{<<"sid">>,<<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>}],[],160,1,<<>>,{{127,0,0,1},50030}}
2015-12-14 16:21:29.389 [debug] <0.1242.0>#ejabberd_http_bind:rid_allow:852 Previous rid / New rid: 1598395/1598396
2015-12-14 16:21:29.389 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:591 Actually processing request: {http_put,1598396,[{<<"xmlns">>,<<"http://jabber.org/protocol/httpbind">>},{<<"content">>,<<"text/xml; charset=utf-8">>},{<<"rid">>,<<"1598396">>},{<<"xml:lang">>,<<"en">>},{<<"sid">>,<<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>}],[],160,1,<<>>,{{127,0,0,1},50030}}
2015-12-14 16:21:29.389 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:642 -- SaveKey:
2015-12-14 16:21:29.389 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:654 reqlist: [{hbr,1598396,<<>>,[]},{hbr,1598395,<<>>,[]}]
2015-12-14 16:21:29.389 [debug] <0.1242.0>#ejabberd_http_bind:process_http_put:700 really sending now: []
2015-12-14 16:23:09.492 [info] <0.1242.0>#ejabberd_http_bind:handle_info:507 Session timeout. Closing the HTTP bind session: <<"92c4475848d8b8f10b4dbe1a66980c385f46ac00">>
2015-12-14 16:23:09.492 [debug] <0.1242.0>#ejabberd_http_bind:terminate:538 terminate: Deleting session 92c4475848d8b8f10b4dbe1a66980c385f46ac00

I was making a mistake in the BoshClient script.
There, in the "startSessionAndAuth" method, you can set the "wait" value, that I don't know in what stages you may want to wait but... it was set to 70 seconds by default. I set it to 0 and now is responding instantly with a new session id.
In the protocol definition its said:
Note: Clients that only support Polling Sessions MAY prevent the
connection manager from waiting by setting 'wait' or 'hold' to "0".
However, polling is NOT RECOMMENDED since the associated increase in
bandwidth consumption and the decrease in responsiveness are both
typically one or two orders of magnitude!
and it's exactly my case.

Related

#Karate Gatling is not generating report when i hit the endpoint once

My Gatling Simulation class,
class <MyClass> extends Simulation {
before {
println("Simulation is about to start!")
}
val smapleTest = scenario("test").exec(karateFeature("classpath:demo/get-user.feature"))
setUp(
smapleTest.inject(rampUsers(1) over (10 seconds))).maxDuration(1 minutes)
//).assertions(global.responseTime.mean.lt(35))
after {
println("Simulation is finished!")
}
}
My get-user.feature file,
Scenario Outline: Hit wskadmin url
Given http://172.17.0.1:5984/whisk_local_subjects/guest
And header Authorization = AdminAuth
And header Content-Type = 'application/json'
When method get
Then status <stat>
* print result
Examples:
| stat |
| 200 |
When i run the simulation class, below console logs i am getting:
Simulation com.karate.openwhisk.performance.SmokePerformanceTest started...
13:20:48.877 [GatlingSystem-akka.actor.default-dispatcher-5] INFO i.gatling.core.controller.Controller - InjectionStopped expectedCount=1
13:20:49.473 [GatlingSystem-akka.actor.default-dispatcher-4] INFO com.intuit.karate - karate.env system property was: null
13:20:49.525 [GatlingSystem-akka.actor.default-dispatcher-7] INFO com.intuit.karate - [print] I am here in get-user
13:20:49.706 [GatlingSystem-akka.actor.default-dispatcher-4] DEBUG com.intuit.karate - request:
1 > GET http://172.17.0.1:5984/whisk_local_subjects/guest
1 > Accept-Encoding: gzip,deflate
1 > Authorization: Basic d2hpc2tfYWRtaW46c29tZV9wYXNzdzByZA==
1 > Connection: Keep-Alive
1 > Content-Type: application/json
1 > Host: 172.17.0.1:5984
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_144)
13:20:49.741 [GatlingSystem-akka.actor.default-dispatcher-4] DEBUG com.intuit.karate - response time in milliseconds: 34
1 < 200
Note: Here i am getting the response in 34 mili seconds, but gating is unable to generate the report. Below is the error message i am getting
Error:
Generating reports...
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
Caused by: java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won't be generated
at io.gatling.charts.report.ReportsGenerator.generateFor(ReportsGenerator.scala:48)
at io.gatling.app.RunResultProcessor.generateReports(RunResultProcessor.scala:76)
at io.gatling.app.RunResultProcessor.processRunResult(RunResultProcessor.scala:55)
at io.gatling.app.Gatling$.start(Gatling.scala:68)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
... 6 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.199 s
[INFO] Finished at: 2018-07-24T13:20:50+05:30
[INFO] Final Memory: 30M/332M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.gatling:gatling-maven-plugin:2.2.4:test (default-cli) on project
openwhisk: Gatling failed.: Process exited with an error: 255 (Exit
value: 255) -> [Help 1]
But if i run the same simulation file simple change in feature file as below
Scenario Outline: Hit wskadmin url
Given http://172.17.0.1:5984/whisk_local_subjects/guest
And header Authorization = AdminAuth
And header Content-Type = 'application/json'
When method get
Then status <stat>
* print result
Examples:
| stat |
| 200 |
| 200 |
Then gatling generates the report.
Please help me someone what is the root cause.
Thank you for your interest in karate-gatling and the very detailed report.
This is a bug, which we have fixed and just made a release for.
Can you upgrade your karate-gatling version to 0.8.0.1 and let me know how it goes ?

docker akka and scala, app start and stop just after without reason

I created a scala App using Akka.
When i run it with : scala /Statistics.jar ./server.conf it works perfectly.
but if I put it in a server or if I put it in a docker image, when i launch it the app start then stop directly after.
Here are my logs :
...
[DEBUG] [02/01/2017 10:26:13.198] [webserver-akka.actor.default-dispatcher-11] [EventStream(akka://version)] logger log1-Slf4jLogger started
[DEBUG] [02/01/2017 10:26:13.185] [subscription-akka.actor.default-dispatcher-4] [akka://subscription/system] now supervising Actor[akka://subscription/system/log1-Slf4jLogger#731298157]
[DEBUG] [02/01/2017 10:26:13.201] [subscription-akka.actor.default-dispatcher-4] [akka://subscription/system] now watched by Actor[akka://subscription/]
[DEBUG] [02/01/2017 10:26:13.202] [webserver-akka.actor.default-dispatcher-11] [EventStream(akka://version)] Default Loggers started
[DEBUG] [02/01/2017 10:26:13.193] [version-akka.actor.default-dispatcher-2] [akka://version/system] now supervising Actor[akka://version/system/log1-Slf4jLogger#1075717908]
[DEBUG] [02/01/2017 10:26:13.206] [session-akka.actor.default-dispatcher-3] [akka://session/system/UnhandledMessageForwarder] started (akka.event.LoggingBus$$anonfun$startDefaultLoggers$2$$anon$3#1b5d5357)
[DEBUG] [02/01/2017 10:26:13.205] [webserver-akka.actor.default-dispatcher-13] [EventStream(akka://session)] Default Loggers started
[DEBUG] [02/01/2017 10:26:13.205] [webserver-akka.actor.default-dispatcher-8] [EventStream(akka://subscription)] Default Loggers started
[DEBUG] [02/01/2017 10:26:13.206] [subscription-akka.actor.default-dispatcher-4] [akka://subscription/system/UnhandledMessageForwarder] started (akka.event.LoggingBus$$anonfun$startDefaultLoggers$2$$anon$3#51839748)
[DEBUG] [02/01/2017 10:26:13.211] [subscription-akka.actor.default-dispatcher-2] [akka://subscription/system] now supervising Actor[akka://subscription/system/UnhandledMessageForwarder#2056207919]
serv http launch
[DEBUG] [02/01/2017 10:26:15.906] [webserver-akka.actor.default-dispatcher-8] [EventStream] shutting down: StandardOutLogger started
[DEBUG] [02/01/2017 10:26:15.909] [webserver-akka.actor.default-dispatcher-8] [EventStream] all default loggers stopped
[DEBUG] [02/01/2017 10:26:15.909] [webserver-akka.actor.default-dispatcher-3] [akka://webserver/system/log1-Slf4jLogger] stopped
[DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-7] [akka://webserver/system/IO-TCP] stopping
[DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-12] [akka://webserver/system/UnhandledMessageForwarder] stopped
[DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-16] [akka://webserver/system/IO-TCP/selectors] stopping
[DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-8] [akka://webserver/system] stopping
[DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-3] [akka://webserver/system/deadLetterListener] stopped
[DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-18] [akka://webserver/system/IO-TCP/selectors/$a] no longer watched by Actor[akka://webserver/system/IO-TCP/selectors#1324110335]
[DEBUG] [02/01/2017 10:26:15.910] [webserver-akka.actor.default-dispatcher-13] [akka://webserver/system/eventStreamUnsubscriber-1] stopped
[DEBUG] [02/01/2017 10:26:15.911] [webserver-akka.actor.default-dispatcher-18] [akka://webserver/system/IO-TCP/selectors/$a] stopped
[DEBUG] [02/01/2017 10:26:15.911] [webserver-akka.actor.default-dispatcher-13] [akka://webserver/system/IO-TCP/selectors] stopped
[DEBUG] [02/01/2017 10:26:15.912] [webserver-akka.actor.default-dispatcher-8] [akka://webserver/system/IO-TCP] stopped
[DEBUG] [02/01/2017 10:26:15.912] [webserver-akka.actor.default-dispatcher-13] [akka://webserver/system] stopped
[DEBUG] [02/01/2017 10:26:15.912] [webserver-akka.actor.default-dispatcher-18] [akka://webserver/] received AutoReceiveMessage Envelope(Terminated(Actor[akka://webserver/system]),Actor[akka://webserver/system])
[DEBUG] [02/01/2017 10:26:15.913] [webserver-akka.actor.default-dispatcher-18] [akka://webserver/] stopped
It seems I can't launch my app in background.
How can i do for launching it in background?
here is my Main.scala:
object WebServer extends App {
implicit val system = ActorSystem("webserver")
implicit val materializer = ActorMaterializer()
// needed for the future flatMap/onComplete in the end
implicit val executionContext = system.dispatcher
val ipServer = InetAddress.getLocalHost().getHostAddress()
val configApplication = ConfigFactory.load("application")
val serverFile = new File(args(0))
val configServer = ConfigFactory.parseFile(serverFile)
val routes =
new AppActiveRoute(system.actorOf(AppActiveHandler.props(), "AppActiveHandler")).route
val bindingFuture = Http().bindAndHandle(
routes,
ipServer,
configApplication.getInt("http.port")
)
println("serv http launch")
StdIn.readLine()
bindingFuture
.flatMap(_.unbind()) // trigger unbinding from the port
.onComplete(_ => {
cluster.close()
system.terminate()
})
bindingFuture.onFailure {
case ex: Exception =>
println(ex, "Failed to bind to {}:{}!", ipServer, configApplication.getInt("http.port"))
}
If your application is supposed to be dockerized and run in a container, you probably don't need this part
StdIn.readLine()
bindingFuture
.flatMap(_.unbind()) // trigger unbinding from the port
.onComplete(_ => {
cluster.close()
system.terminate()
})
Try deleting it.
If you care to gracefully shutdown your actor system when the VM exits, you can use a shutdown hook, as specified in this answer.

Tsung load testing not able to send message ejabberd server

I am new to this tsung load testing framework, since last one week i have been exploring this tool to load test my ejabberd server till now i am able to register some 200 users at one go that is awesome, i am able to generate report Graphs (right now it is blank all over).
My problem is I am not able to send message from the sendmessage.xml file to my any other user through I am new to this tsung load testing framework, since last one week i have been exploring this tool to load test my ejabberd server till now i am able to register some 200 users at one go that is awesome, i am able to generate report Graphs (right now it is blank all over).
My problem is I am not able to send message from the sendmessage.xml file to my any other user through my ejabberd instance here is my sendmessage.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE tsung SYSTEM "/usr/share/tsung/tsung-1.0.dtd" [] >
<tsung loglevel="info" backend="json">
<clients>
<client host="localhost" use_controller_vm="true"/>
</clients>
<servers>
<server host="*.*.*.*" port="5222" type="tcp"/>
</servers>
<load duration="12" unit="minute">
<arrivalphase phase="1" duration="12" unit="minute">
<users maxnumber="100" interarrival="1" unit="second"></users>
</arrivalphase>
</load>
<options>
<option type="ts_jabber" name="global_number" value="5"></option>
<option type="ts_jabber" name="userid_max" value="200000" />
<option type="ts_jabber" name="domain" value="hostname.com" />
<option type="ts_jabber" name="username" value="andupandu" />
<option type="ts_jabber" name="passwd" value="password" />
</options>
<sessions>
<session probability="100" name="xmpp-connection" type="ts_jabber">
<request> <jabber type="connect" ack="local"></jabber> </request>
<thinktime value="2"></thinktime>
<request><jabber type="starttls" ack="bidi_ack" />
</request>
<thinktime value="5"></thinktime>
<transaction name="authenticate">
<request> <jabber type="auth_sasl_anonymous" ack="local"></jabber> </request>
<request> <jabber type="connect" ack="local"></jabber> </request>
<request> <jabber type="auth_sasl_bind" ack="local" ></jabber></request>
<request> <jabber type="auth_sasl_session" ack="local" ></jabber></request>
<request> <jabber type="presence:initial" ack="no_ack"/> </request>
</transaction>
<thinktime value="5"></thinktime>
<transaction name="online">
<request> <jabber type="chat" ack="no_ack" size="4000" destination="online"/></request>
</transaction>
<transaction name="close">
<request> <jabber type="close" ack="local"></jabber> </request>
</transaction>
</session>
</sessions>
</tsung>
While running this script i was going my ejabberd.log file this is coming
2016-12-19 11:02:43.553 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30840>) Accepted connection 223.30.185.182:46844 -> 122.166.14.59:5222
2016-12-19 11:02:43.772 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30841>) Accepted connection 223.30.185.182:48205 -> 122.166.14.59:5222
2016-12-19 11:02:44.266 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30842>) Accepted connection 223.30.185.182:48358 -> 122.166.14.59:5222
2016-12-19 11:02:45.530 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30843>) Accepted connection 223.30.185.182:46427 -> 122.166.14.59:5222
2016-12-19 11:02:45.689 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30844>) Accepted connection 223.30.185.182:48789 -> 122.166.14.59:5222
2016-12-19 11:02:46.872 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30845>) Accepted connection 223.30.185.182:34836 -> 122.166.14.59:5222
2016-12-19 11:02:48.092 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30846>) Accepted connection 223.30.185.182:33801 -> 122.166.14.59:5222
2016-12-19 11:02:49.144 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30847>) Accepted connection 223.30.185.182:33990 -> 122.166.14.59:5222
2016-12-19 11:02:50.479 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30848>) Accepted connection 223.30.185.182:50522 -> 122.166.14.59:5222
2016-12-19 11:02:51.676 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30849>) Accepted connection 223.30.185.182:40768 -> 122.166.14.59:5222
2016-12-19 11:02:52.925 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30850>) Accepted connection 223.30.185.182:57973 -> 122.166.14.59:5222
2016-12-19 11:02:53.759 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30851>) Accepted connection 223.30.185.182:41619 -> 122.166.14.59:5222
2016-12-19 11:02:54.371 [info] <0.606.0>#ejabberd_listener:accept:333 (#Port<0.30852>) Accepted connection 223.30.185.182:42115 -> 122.166.14.59:5222
... and similar
the problem is session is not getting created
and folowing tsung.log i am getting
{
"stats": [
{"timestamp": 1482142630, "samples": []},
{"timestamp": 1482142640, "samples": [ {"name": "users", "value": 3, "max": 3}, {"name": "cpu", "hostname": "neureol", "value": 1, "mean": 5.301845187701585,"stddev": 0,"max": 5.301845187701585,"min": 5.301845187701585 ,"global_mean": 0 ,"global_count": 0}, {"name": "load", "hostname": "neureol", "value": 1, "mean": 0.37109375,"stddev": 0,"max": 0.37109375,"min": 0.37109375 ,"global_mean": 0 ,"global_count": 0}, {"name": "freemem", "hostname": "neureol", "value": 1, "mean": 4278.2265625,"stddev": 0,"max": 4278.2265625,"min": 4278.2265625 ,"global_mean": 0 ,"global_count": 0}, {"name": "users_count", "value": 3, "total": 3}, {"name": "finish_users_count", "value": 0, "total": 0}, {"name": "request", "value": 3, "mean": 264.84033203125,"stddev": 88.15162068742659,"max": 389.04296875,"min": 193.447021484375 ,"global_mean": 0 ,"global_count": 0}, {"name": "connect", "value": 3, "mean": 125.679931640625,"stddev": 42.371197826714514,"max": 185.3427734375,"min": 91.028076171875 ,"global_mean": 0 ,"global_count": 0}, {"name": "page", "value": 3, "mean": 264.84033203125,"stddev": 88.15162068742659,"max": 389.04296875,"min": 193.447021484375 ,"global_mean": 0 ,"global_count": 0}, {"name": "size_rcv", "value": 2024, "total": 2024}, {"name": "size_sent", "value": 501, "total": 501}, {"name": "connected", "value": 3, "max": 3}]},
{"timestamp": 1482142650, "samples": [ {"name": "users", "value": 7, "max": 7}, {"name": "cpu", "hostname": "neureol", "value": 1, "mean": 7.1357035553329995,"stddev": 0.0,"max": 7.1357035553329995,"min": 5.301845187701585 ,"global_mean": 5.301845187701585 ,"global_count": 1}, {"name": "load", "hostname": "neureol", "value": 1, "mean": 0.30859375,"stddev": 0.0,"max": 0.37109375,"min": 0.30859375 ,"global_mean": 0.37109375 ,"global_count": 1}, {"name": "freemem", "hostname": "neureol", "value": 1, "mean": 4275.30078125,"stddev": 0.0,"max": 4278.2265625,"min": 4275.30078125 ,"global_mean": 4278.2265625 ,"global_count": 1}, {"name": "users_count", "value": 4, "total": 7}, {"name": "finish_users_count", "value": 0, "total": 0}, {"name": "request", "value": 4, "mean": 522.1024780273438,"stddev": 425.6234764859712,"max": 1257.77099609375,"min": 193.447021484375 ,"global_mean": 264.84033203125 ,"global_count": 3}, {"name": "connect", "value": 4, "mean": 398.53875732421875,"stddev": 438.4391252124725,"max": 1156.155029296875,"min": 91.028076171875 ,"global_mean": 125.679931640625 ,"global_count": 3}, {"name": "page", "value": 4, "mean": 522.1024780273438,"stddev": 425.6234764859712,"max": 1257.77099609375,"min": 193.447021484375 ,"global_mean": 264.84033203125 ,"global_count": 3}, {"name": "size_rcv", "value": 2784, "total": 4808}, {"name": "size_sent", "value": 753, "total": 1254}, {"name": "connected", "value": 4, "max": 7}]}]}
If you see the tsung.log which is showing similar to {"name": "connected", "value": 3, "max": 3} how it is coming since there is no any log present there on ejbbered side .
After running perl script i am getting totally blank report with graph.
Here is my ijabberd.yml is :-
loglevel: 4
log_rotate_size: 10485760
log_rotate_date: ""
log_rotate_count: 1
log_rate_limit: 100
hosts:
- "something.com"
- "122.166.14.59"
- "demo.something.com"
listen:
-
port: 5222
module: ejabberd_c2s
certfile: "/opt/ejabberd-16.06/conf/server.pem"
starttls: true
## To enforce TLS encryption for client connections,
## use this instead of the "starttls" option:
## starttls_required: true
##
## Custom OpenSSL options
##
protocol_options:
- "no_sslv3"
## - "no_tlsv1"
max_stanza_size: 65536
shaper: c2s_shaper
access: c2s
resend_on_timeout: true
-
port: 5269
module: ejabberd_s2s_in
max_stanza_size: 131072
shaper: s2s_shaper
-
port: 5280
module: ejabberd_http
request_handlers:
"/websocket": ejabberd_http_ws
## "/pub/archive": mod_http_fileserver
web_admin: true
http_bind: true
## register: true
captcha: false
auth_method: internal
auth_method: anonymous
anonymous_protocol: both
allow_multiple_connections: true
host_config:
"something.com":
odbc_type: mysql
odbc_server: "localhost"
odbc_database: "chatdb"
odbc_username: "siteuser"
odbc_password: "site!##$"
auth_method: [odbc]
shaper:
##
## The "normal" shaper limits traffic speed to 1000 B/s
##
normal: 1000
##
## The "fast" shaper limits traffic speed to 50000 B/s
##
fast: 500000000
max_fsm_queue: 1000
shaper_rules:
## Maximum number of simultaneous sessions allowed for a single user:
max_user_sessions: 10
## Maximum number of offline messages that users can have:
max_user_offline_messages:
- allow: all
## For C2S connections, all users except admins use the "normal" shaper
c2s_shaper:
- none: admin
- fast
## All S2S connections use the "fast" shaper
s2s_shaper: fast
access_rules:
## This rule allows access only for local users:
local:
- allow: local
## Only non-blocked users can use c2s connections:
c2s:
- deny: blocked
- allow
## Only admins can send announcement messages:
announce:
- allow: admin
## Only admins can use the configuration interface:
configure:
- allow: admin
## Only accounts of the local ejabberd server can create rooms:
muc_create:
- allow: local
## Only accounts on the local ejabberd server can create Pubsub nodes:
pubsub_createnode:
- allow: local
## In-band registration allows registration of any possible username.
## To disable in-band registration, replace 'allow' with 'deny'.
register:
- allow
## Only allow to register from localhost
trusted_network:
- allow: all
registration_timeout: infinity
modules:
mod_adhoc: {}
mod_admin_extra: {}
mod_announce: # recommends mod_adhoc
access: announce
mod_blocking: {} # requires mod_privacy
mod_caps: {}
mod_carboncopy: {}
mod_client_state: {}
mod_configure: {} # requires mod_adhoc
mod_disco: {}
## mod_echo: {}
mod_http_bind: {}
mod_last: {}
mod_muc:
access:
- allow
access_admin:
- allow: admin
access_create: muc_create
access_persistent: muc_create
mod_muc_admin: {}
## mod_muc_log: {}
## mod_multicast: {}
mod_offline:
access_max_user_messages: max_user_offline_messages
mod_ping:
send_pings: true
ping_interval: 60
ping_ack_timout: 32
timeout_action: kill
mod_privacy: {}
mod_private: {}
mod_pubsub:
access_createnode: pubsub_createnode
## reduces resource comsumption, but XEP incompliant
ignore_pep_from_offline: true
## XEP compliant, but increases resource comsumption
## ignore_pep_from_offline: false
last_item_cache: false
plugins:
- "flat"
- "hometree"
- "pep" # pep requires mod_caps
mod_register:
welcome_message:
subject: "Welcome!"
body: |-
Hi.
Welcome to this XMPP server.
access: register
mod_roster: {}
mod_shared_roster: {}
mod_vcard:
search: false
mod_version: {}
allow_contrib_modules: true
After changing the ejabber log to 5 here is the ejabber.logs are :
2016-12-20 12:35:09.694 [info] <0.3540.1>#ejabberd_listener:accept:333 (#Port<0.123804>) Accepted connection 223.30.185.182:44998 -> *.*.*.*:5222
2016-12-20 12:35:09.696 [debug] <0.8478.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?><stream:stream id='1' to='something.com' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>">>
2016-12-20 12:35:09.696 [debug] <0.8479.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='12153081287775773739' from='something.com' version='1.0' xml:lang='en'>">>
2016-12-20 12:35:09.697 [debug] <0.8479.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='Xe/lYmivnmPRh4GEsNf6U13V4G8='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2016-12-20 12:35:10.043 [info] <0.3540.1>#ejabberd_listener:accept:333 (#Port<0.123801>) Accepted connection 223.30.185.182:36296 -> *.*.*.*:5222
2016-12-20 12:35:10.044 [debug] <0.8480.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?><stream:stream id='2' to='something.com' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>">>
2016-12-20 12:35:10.044 [debug] <0.8481.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='3424930239190161372' from='something.com' version='1.0' xml:lang='en'>">>
2016-12-20 12:35:10.045 [debug] <0.8481.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='Xe/lYmivnmPRh4GEsNf6U13V4G8='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2016-12-20 12:35:11.173 [info] <0.3540.1>#ejabberd_listener:accept:333 (#Port<0.123807>) Accepted connection 223.30.185.182:35101 -> *.*.*.*:5222
2016-12-20 12:35:11.175 [debug] <0.8482.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?><stream:stream id='3' to='something.com' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>">>
2016-12-20 12:35:11.175 [debug] <0.8483.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='10270498772362791845' from='something.com' version='1.0' xml:lang='en'>">>
2016-12-20 12:35:11.176 [debug] <0.8483.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='Xe/lYmivnmPRh4GEsNf6U13V4G8='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2016-12-20 12:35:11.872 [debug] <0.8478.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>">>
2016-12-20 12:35:11.872 [debug] <0.8478.1>#shaper:update:120 State: {maxrate,500000000,0.0,1482217509697017}, Size=51
M=5.1e-5, I=2175.696
2016-12-20 12:35:11.873 [debug] <0.8478.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<>>
2016-12-20 12:35:11.873 [debug] <0.8478.1>#shaper:update:120 State: {maxrate,500000000,11.719617122406575,1482217511872856}, Size=0
M=0.0, I=0.328
2016-12-20 12:35:12.157 [debug] <0.8480.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>">>
2016-12-20 12:35:12.157 [debug] <0.8480.1>#shaper:update:120 State: {maxrate,500000000,0.0,1482217510044454}, Size=51
M=5.1e-5, I=2113.04
2016-12-20 12:35:12.157 [debug] <0.8480.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<>>
2016-12-20 12:35:12.158 [debug] <0.8480.1>#shaper:update:120 State: {maxrate,500000000,12.067047354406341,1482217512157647}, Size=0
M=0.0, I=0.311
2016-12-20 12:35:13.303 [debug] <0.8482.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>">>
2016-12-20 12:35:13.303 [debug] <0.8482.1>#shaper:update:120 State: {maxrate,500000000,0.0,1482217511175417}, Size=51
M=5.1e-5, I=2128.331
2016-12-20 12:35:13.304 [debug] <0.8482.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<>>
2016-12-20 12:35:13.304 [debug] <0.8482.1>#shaper:update:120 State: {maxrate,500000000,11.980431023020751,1482217513303888}, Size=0
M=0.0, I=0.368
2016-12-20 12:35:15.202 [info] <0.3540.1>#ejabberd_listener:accept:333 (#Port<0.123812>) Accepted connection 223.30.185.182:49986 -> *.*.*.*:5222
2016-12-20 12:35:15.203 [debug] <0.8484.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?><stream:stream id='4' to='something.com' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>">>
2016-12-20 12:35:15.203 [debug] <0.8485.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='6574869083255218624' from='something.com' version='1.0' xml:lang='en'>">>
2016-12-20 12:35:15.204 [debug] <0.8485.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='Xe/lYmivnmPRh4GEsNf6U13V4G8='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2016-12-20 12:35:15.504 [info] <0.3540.1>#ejabberd_listener:accept:333 (#Port<0.123810>) Accepted connection 223.30.185.182:41718 -> *.*.*.*:5222
2016-12-20 12:35:15.505 [debug] <0.8486.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?><stream:stream id='5' to='something.com' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>">>
2016-12-20 12:35:15.506 [debug] <0.8487.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='11910276457718456980' from='something.com' version='1.0' xml:lang='en'>">>
2016-12-20 12:35:15.507 [debug] <0.8487.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='Xe/lYmivnmPRh4GEsNf6U13V4G8='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2016-12-20 12:35:16.979 [info] <0.3540.1>#ejabberd_listener:accept:333 (#Port<0.123799>) Accepted connection 223.30.185.182:57791 -> *.*.*.*:5222
2016-12-20 12:35:16.980 [debug] <0.8488.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?><stream:stream id='6' to='something.com' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>">>
2016-12-20 12:35:16.980 [debug] <0.8489.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='16257359711038503484' from='something.com' version='1.0' xml:lang='en'>">>
2016-12-20 12:35:16.981 [debug] <0.8489.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='Xe/lYmivnmPRh4GEsNf6U13V4G8='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2016-12-20 12:35:17.486 [debug] <0.8484.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>">>
2016-12-20 12:35:17.487 [debug] <0.8484.1>#shaper:update:120 State: {maxrate,500000000,0.0,1482217515203642}, Size=51
M=5.1e-5, I=2283.43
2016-12-20 12:35:17.487 [debug] <0.8484.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<>>
2016-12-20 12:35:17.487 [debug] <0.8484.1>#shaper:update:120 State: {maxrate,500000000,11.166760014941563,1482217517487205}, Size=0
M=0.0, I=0.271
2016-12-20 12:35:17.756 [debug] <0.8486.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>">>
2016-12-20 12:35:17.756 [debug] <0.8486.1>#shaper:update:120 State: {maxrate,500000000,0.0,1482217515505921}, Size=51
M=5.1e-5, I=2250.965
2016-12-20 12:35:17.757 [debug] <0.8486.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<>>
2016-12-20 12:35:17.757 [debug] <0.8486.1>#shaper:update:120 State: {maxrate,500000000,11.32786071795537,1482217517757008}, Size=0
M=0.0, I=0.314
2016-12-20 12:35:17.793 [info] <0.3540.1>#ejabberd_listener:accept:333 (#Port<0.123817>) Accepted connection 223.30.185.182:42577 -> *.*.*.*:5222
2016-12-20 12:35:17.803 [debug] <0.8490.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?><stream:stream id='7' to='something.com' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>">>
2016-12-20 12:35:17.803 [debug] <0.8491.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='3919444622270218959' from='something.com' version='1.0' xml:lang='en'>">>
2016-12-20 12:35:17.804 [debug] <0.8491.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='Xe/lYmivnmPRh4GEsNf6U13V4G8='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2016-12-20 12:35:18.762 [info] <0.3540.1>#ejabberd_listener:accept:333 (#Port<0.123818>) Accepted connection 223.30.185.182:37374 -> *.*.*.*:5222
2016-12-20 12:35:18.763 [debug] <0.8492.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<?xml version='1.0'?><stream:stream id='8' to='something.com' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>">>
2016-12-20 12:35:18.763 [debug] <0.8493.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='11192005229436680642' from='something.com' version='1.0' xml:lang='en'>">>
2016-12-20 12:35:18.764 [debug] <0.8493.1>#ejabberd_c2s:send_text:1852 Send XML on stream = <<"<stream:features><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.process-one.net/en/ejabberd/' ver='Xe/lYmivnmPRh4GEsNf6U13V4G8='/><register xmlns='http://jabber.org/features/iq-register'/><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>">>
2016-12-20 12:35:19.210 [debug] <0.8488.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<"<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>">>
2016-12-20 12:35:19.210 [debug] <0.8488.1>#shaper:update:120 State: {maxrate,500000000,0.0,1482217516980265}, Size=51
M=5.1e-5, I=2230.46
2016-12-20 12:35:19.211 [debug] <0.8488.1>#ejabberd_receiver:process_data:284 Received XML on stream = <<>>
2016-12-20 12:35:19.211 [debug] <0.8488.1>#shaper:update:120 State: {maxrate,500000000,11.43193760582948,1482217519210858}, Size=0
M=0.0, I=0.277
Here is an example of my tsung xml file which working well with starttls:
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/home/ubuntu/tsung-1.7.0/tsung-1.0.dtd" []>
<tsung loglevel="warning" dumptraffic="false" version="1.0">
<clients>
<client host="localhost" use_controller_vm="false" cpu="8" maxusers="100000">
</client>
</clients>
<servers>
<server host="xmpp.example.com" port="5222" type="tcp"/>
</servers>
<load duration="30" unit="minute">
<!--user session="jabber-login" start_time="2" unit="second"></user-->
<!-- to make 24k online users -->
<arrivalphase phase="1" duration="30" unit="minute">
<users arrivalrate="20" unit="second"></users>
<session_setup name="jabber-login" probability="100"/>
</arrivalphase>
</load>
<options>
<option type="ts_jabber" name="global_number" value="500"/>
<option type="ts_jabber" name="userid_max" value="1000000"/>
<option type="ts_jabber" name="domain" value="mylowdown.com"/>
<option type="ts_jabber" name="username" value="tsung_"/>
<option type="ts_jabber" name="passwd" value="tsung_pwd"/>
</options>
<sessions>
<session probability="0" name="jabber-login" type="ts_jabber" bidi="true">
<transaction name="connect">
<request> <jabber type="connect" ack="local" /> </request>
<thinktime value="5"></thinktime>
<request> <jabber type="starttls" ack="bidi_ack" /> </request>
<request> <jabber type="connect" ack="local" /> </request>
</transaction>
<thinktime value="5"></thinktime>
<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="online">
<request> <jabber type="presence:initial" ack="no_ack"/> </request>
</transaction>
<thinktime value="5"></thinktime>
<for var="counter" from="1" to="21" incr="1">
<transaction name="online_msg">
<request>
<jabber type="chat" ack="no_ack" size="40" stamped="true" destination="online"/>
</request>
</transaction>
<thinktime value="15"/>
<transaction name="offline_msg">
<request>
<jabber type="chat" ack="no_ack" size="10" stamped="true" destination="offline"/>
</request>
</transaction>
<thinktime value="15"/>
</for>
<transaction name="close">
<request> <jabber type="close" ack="local"> </jabber></request>
</transaction>
</session>
</sessions>
</tsung>

org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2

I am using scalatest as my testing framework, here is my test code :
import org.scalatest.FunSuite
class SampleTest extends FunSuite{
test("hello") {
println(s"sdfsf")
}
}
build.sbt settings
val scalatestJS = libraryDependencies += "org.scalatest" %%% "scalatest" % Version.scalatest % Test
val scalatestJSSettings = Seq(
scalatestJS,
scalaJSStage in Global := FastOptStage,
// scalaJSStage in Global := FullOptStage,
// jsDependencies += RuntimeDOM,
// jsDependencies += ProvidedJS / "test-bundle.js" % Test,
jsEnv in Test := new PhantomJS2Env(scalaJSPhantomJSClassLoader.value, addArgs = Seq("--web-security=no"))
// jsEnv in Test := new NodeJSEnv()
)
Debug out :
[debug] Scala compilation took 0.961938628 s
[debug] Invalidating client/SampleTest.scala...
[debug] Invalidating (transitively) by inheritance from client/SampleTest.scala...
[debug] Initial set of included nodes: Set(client/SampleTest.scala)
[debug] Invalidated by transitive inheritance dependency: Set(client/SampleTest.scala)
[debug] The client/SampleTest.scala source file has the following implicit definitions changed:
[debug] unconstrainedEquality, convertToEqualizer.
[debug] All member reference dependencies will be considered within this context.
[debug] New invalidations:
[debug] Set()
[debug] Initial set of included nodes: Set()
[debug] Previously invalidated, but (transitively) depend on new invalidations:
[debug] Set()
[debug] All newly invalidated sources after taking into account (previously) recompiled sources:Set()
[debug] Copy resource mappings:
[debug]
[info] Fast optimizing client/assets/client-test-fastopt.js
[debug] Linker: Compute reachability: 710892 us
[debug] Linker: Assemble LinkedClasses: 445560 us
[debug] Basic Linking: 1168893 us
[debug] Inc. optimizer: Batch mode: true
[debug] Inc. optimizer: Incremental part: 127681 us
[debug] Inc. optimizer: Optimizing 11793 methods.
[debug] Inc. optimizer: Optimizer part: 5987357 us
[debug] Inc. optimizer: 6140114 us
[debug] Refiner: Compute reachability: 243271 us
[debug] Refiner: Assemble LinkedClasses: 27389 us
[debug] Refiner: 272567 us
[debug] Emitter: Class tree cache stats: reused: 0 -- invalidated: 1375
[debug] Emitter: Method tree cache stats: resued: 0 -- invalidated: 6643
[debug] Emitter (write output): 1353125 us
[debug] Global IR cache stats: reused: 0 -- invalidated: 130 -- trees read: 1748
[debug] Loading JSEnv with linked file client/assets/client-test-fastopt.js
org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2
at org.scalajs.jsenv.ExternalJSEnv$AbstractExtRunner.waitForVM(ExternalJSEnv.scala:107)
at org.scalajs.jsenv.ExternalJSEnv$ExtRunner.run(ExternalJSEnv.scala:156)
at org.scalajs.sbtplugin.FrameworkDetector.detect(FrameworkDetector.scala:66)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$60.apply(ScalaJSPluginInternal.scala:737)
at org.scalajs.sbtplugin.ScalaJSPluginInternal$$anonfun$60.apply(ScalaJSPluginInternal.scala:720)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
at sbt.std.Transform$$anon$4.work(System.scala:63)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.Execute.work(Execute.scala:235)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[error] (client/test:loadedTestFrameworks) org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: PhantomJS2 exited with code 2
[error] Total time: 15 s, completed May 20, 2016 12:20:29 AM
Note : This is used to work fine but not anymore :s
Edit :
ScalaTest : 3.0.0-M15
ScalaJS : 0.6.9
Scala : 2.11.8
Phantom JS : 2.0.0
In my code i have a class which extends js class
#ScalaJSDefined
class MyLab(container : dom.Node) extends JSLab(container) {... }
even though i am not using this class in my tests,looks like source code generated for this line is some how looking for JSLab in global! which causes crash of phantomjs. Interestingly tests are executing fine on Rhino :s. anyhow i added JSLab as test dependency and error gone.
I don't know whom to blame here , whether its stupid developer(me) who went in different direction while solving problem or scala.js for not helpful in why phantomjs crashed :s

Why is my spring boot stateless filter being called twice?

I'm trying to implement stateless token-based authentication on a rest api I've developed using Spring Boot. The idea is that the client includes a JWT token with any request, and a filter extracts this from the request, and sets up the SecurityContext with a relevant Authentication object based on the contents of the token. The request is then routed as normal, and secured using #PreAuthorize on the mapped method.
My security config is as follows :
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
#Autowired
private JWTTokenAuthenticationService authenticationService;
#Override
protected void configure(HttpSecurity http) throws Exception
{
http
.csrf().disable()
.headers().addHeaderWriter(new XFrameOptionsHeaderWriter(XFrameOptionsMode.SAMEORIGIN))
.and()
.authorizeRequests()
.antMatchers("/auth/**").permitAll()
.antMatchers("/api/**").authenticated()
.and()
.addFilterBefore(new StatelessAuthenticationFilter(authenticationService), UsernamePasswordAuthenticationFilter.class);
}
With the stateless filter that extends GenericFilterBean defined as follows :
public class StatelessAuthenticationFilter extends GenericFilterBean {
private static Logger logger = Logger.getLogger(StatelessAuthenticationFilter.class);
private JWTTokenAuthenticationService authenticationservice;
public StatelessAuthenticationFilter(JWTTokenAuthenticationService authenticationService)
{
this.authenticationservice = authenticationService;
}
#Override
public void doFilter( ServletRequest request,
ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
Authentication authentication = authenticationservice.getAuthentication(httpRequest);
SecurityContextHolder.getContext().setAuthentication(authentication);
logger.info("===== Security Context before request =====");
logger.info("Request for: " + httpRequest.getRequestURI());
logger.info(SecurityContextHolder.getContext().getAuthentication());
logger.info("===========================================");
chain.doFilter(request, response);
SecurityContextHolder.getContext().setAuthentication(null);
logger.info("===== Security Context after request =====");
logger.info("Request for: " + httpRequest.getRequestURI());
logger.info(SecurityContextHolder.getContext().getAuthentication());
logger.info("===========================================");
}
}
And the endpoint defined like this :
#PreAuthorize("hasAuthority('user')")
#RequestMapping ( value="/api/attachments/{attachmentId}/{fileName:.+}",
method = RequestMethod.GET)
public ResponseEntity<byte[]> getAttachedDocumentEndpoint(#PathVariable String attachmentId, #PathVariable String fileName)
{
logger.info("GET called for /attachments/" + attachmentId + "/" + fileName);
// do something to get the file, and return ResponseEntity<byte[]> object
}
When doing a GET on /api/attachments/someattachment/somefilename, including the token, I can see that the filter is being invoked twice, once apparently with the token, and once without. But the restcontroller mapped to the request is only called once.
[INFO] [06-04-2015 12:26:44,465] [JWTTokenAuthenticationService] getAuthentication - Getting authentication based on token supplied in HTTP Header
[INFO] [06-04-2015 12:26:44,473] [StatelessAuthenticationFilter] doFilter - ===== Security Context before request =====
[INFO] [06-04-2015 12:26:44,473] [StatelessAuthenticationFilter] doFilter - Request for: /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,474] [StatelessAuthenticationFilter] doFilter - Name:iser, Principal:user, isAuthenticated:true, grantedAuthorites:[user]
[INFO] [06-04-2015 12:26:44,474] [StatelessAuthenticationFilter] doFilter - ===========================================
[INFO] [06-04-2015 12:26:44,476] [AttachmentRESTController] getAttachedDocumentEndpoint - GET called for /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,477] [AttachmentDBController] getAttachment - getAttachment method called with attachmentId:1674b08b6bbd54a6efaff4a780001a9e , and fileName:jpg.png
[INFO] [06-04-2015 12:26:44,483] [StatelessAuthenticationFilter] doFilter - ===== Security Context after request =====
[INFO] [06-04-2015 12:26:44,484] [StatelessAuthenticationFilter] doFilter - Request for: /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,484] [StatelessAuthenticationFilter] doFilter -
[INFO] [06-04-2015 12:26:44,484] [StatelessAuthenticationFilter] doFilter - ===========================================
[INFO] [06-04-2015 12:26:44,507] [JWTTokenAuthenticationService] getAuthentication - No token supplied in HTTP Header
[INFO] [06-04-2015 12:26:44,507] [StatelessAuthenticationFilter] doFilter - ===== Security Context before request =====
[INFO] [06-04-2015 12:26:44,507] [StatelessAuthenticationFilter] doFilter - Request for: /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,507] [StatelessAuthenticationFilter] doFilter -
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter - ===========================================
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter - ===== Security Context after request =====
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter - Request for: /api/attachments/1674b08b6bbd54a6efaff4a780001a9e/jpg.png
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter -
[INFO] [06-04-2015 12:26:44,508] [StatelessAuthenticationFilter] doFilter - ===========================================
What's going on here ?
Edit :
It's even stranger than I first thought - implementing a simple endpoint that just returns a simple message displays the expected behaviour - it's seems like only when I try to return data as a ResponseEntity as above does this problem occur.
Endpoint :
#PreAuthorize("hasAuthority('user')")
#RequestMapping("/api/userHelloWorld")
public String userHelloWorld()
{
return "Hello Secure User World";
}
Output, showing single call to filter (with extra debug on):
[INFO] [06-04-2015 19:43:25,831] [JWTTokenAuthenticationService] getAuthentication - Getting authentication based on token supplied in HTTP Header
[INFO] [06-04-2015 19:43:25,844] [StatelessAuthenticationFilter] doFilterInternal - ===== Security Context before request =====
[INFO] [06-04-2015 19:43:25,844] [StatelessAuthenticationFilter] doFilterInternal - Request for: /api/userHelloWorld
[INFO] [06-04-2015 19:43:25,844] [StatelessAuthenticationFilter] doFilterInternal - Response = null 200
[INFO] [06-04-2015 19:43:25,844] [StatelessAuthenticationFilter] doFilterInternal - Name:user, Principal:user, isAuthenticated:true, grantedAuthorites:[user]
[INFO] [06-04-2015 19:43:25,845] [StatelessAuthenticationFilter] doFilterInternal - ===========================================
[DEBUG] [06-04-2015 19:43:25,845] [DispatcherServlet] doService - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/api/userHelloWorld]
[DEBUG] [06-04-2015 19:43:25,847] [AbstractHandlerMethodMapping] getHandlerInternal - Looking up handler method for path /api/userHelloWorld
[DEBUG] [06-04-2015 19:43:25,848] [AbstractHandlerMethodMapping] getHandlerInternal - Returning handler method [public java.lang.String RESTController.userHelloWorld()]
[DEBUG] [06-04-2015 19:43:25,849] [DispatcherServlet] doDispatch - Last-Modified value for [/api/userHelloWorld] is: -1
[DEBUG] [06-04-2015 19:43:25,851] [AbstractMessageConverterMethodProcessor] writeWithMessageConverters - Written [Hello Secure User World] as "text/plain;charset=UTF-8" using [org.springframework.http.converter.StringHttpMessageConverter#3eaf6fe7]
[DEBUG] [06-04-2015 19:43:25,852] [DispatcherServlet] processDispatchResult - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
[DEBUG] [06-04-2015 19:43:25,852] [FrameworkServlet] processRequest - Successfully completed request
[INFO] [06-04-2015 19:43:25,852] [StatelessAuthenticationFilter] doFilterInternal - ===== Security Context after request =====
[INFO] [06-04-2015 19:43:25,853] [StatelessAuthenticationFilter] doFilterInternal - Request for: /api/userHelloWorld
[INFO] [06-04-2015 19:43:25,853] [StatelessAuthenticationFilter] doFilterInternal - Response = text/plain;charset=UTF-8 200
[INFO] [06-04-2015 19:43:25,853] [StatelessAuthenticationFilter] doFilterInternal -
[INFO] [06-04-2015 19:43:25,853] [StatelessAuthenticationFilter] doFilterInternal - ===========================================
It is a part of filters that has still some black magic for me (*), but I know that this is a common problem, and Spring has a subclass of GenericFilterBean specially for dealing with it : just use OncePerRequestFilter as base class and your filter should be called only once.
(*) I've read it could be caused by the request being dispatched multiple times via the request dispatcher
Okay - so this is pretty ridiculous, but it seems like it's an issue with the way I was invoking the request (via the POSTMAN Chrome Extension)
Postman seems to fire in 2 requests, one with headers, one without. There's an open bug report describing this here :
https://github.com/a85/POSTMan-Chrome-Extension/issues/615
The behaviour is not seen if the request is invoked using curl, or just straight from the browser.